Vue#
This guide shows how to point a Vue app at Pinstripe's ESLint and Prettier presets.
Install#
Add Pinstripe as a dev dependency:
npm install --save-dev @waynestate/pinstripe eslint prettier
Configure ESLint#
Create eslint.config.js and spread the preset. For TypeScript:
import pinstripe from '@waynestate/pinstripe/eslint/typescript'
export default [...pinstripe]
For plain JavaScript, import @waynestate/pinstripe/eslint/javascript instead.
Typed linting#
The TypeScript preset lints with types (typescript-eslint's recommendedTypeChecked, through projectService), so it catches what the syntax alone cannot. A promise nobody awaits is the classic: the save button looks done, and the error vanishes into the night.
async function save(): Promise<void> {}
save() // @typescript-eslint/no-floating-promises: await it, return it, or mark it with void
That fails lint in a .ts file and in a .vue file's <script setup lang="ts"> alike. The preset reads the app's tsconfig.json, so that file must include the .ts and .vue files you lint. Typed linting is slower than syntax linting, so run it in CI rather than on every save.
Proven on fixtures: tests/js/typed holds a clean .ts file that must pass, and a floating promise in floating.ts and in FloatingSave.vue that must each fail with @typescript-eslint/no-floating-promises as an error (npm test).
Configure Prettier#
Point Prettier at the preset in package.json:
{
"prettier": "@waynestate/pinstripe/prettier"
}
Add scripts#
Add scripts that run on every OS:
{
"scripts": {
"lint": "eslint .",
"format": "prettier --write ."
}
}
npm run lint fails on style and accessibility, and on every Vue and accessibility finding: where the plugins' recommended configs report a rule as a warning, Pinstripe reports it as an error, so the editor, a local run and CI all agree on what fails. npm run format fixes the layout.
An app that cannot fix every finding in one cut can spread the -warn twin for a while (@waynestate/pinstripe/eslint/javascript-warn or @waynestate/pinstripe/eslint/typescript-warn): the same rules with the plugins' original severities, so findings that were warnings stay warnings. Switch back to the strict preset once the codebase is clean. The preset is the off-the-rack suit: it fits every app, and you only add your own cufflinks.