Shared ESLint config used in Mobile Jazz projects.
This is meant to be used alongside Prettier (with @mobilejazz/prettier-config
).
-
Remove existing
.eslintrc.*
file, if present. -
Install
eslint
and the config.npm install -D eslint @mobilejazz/eslint-config
-
Install all the needed dependencies from this library
npx install-peerdeps --dev @mobilejazz/eslint-config
-
Add the lint configuration that you need to your
package.json
,javascipt
,typescript
orangular
:"eslintConfig": { "extends": "@mobilejazz/eslint-config/angular" }
-
Set up Prettier and
@mobilejazz/prettier-config
. -
When using with Prettier and
@mobilejazz/prettier-config
, ESLint should run first. Set up your scripts inpackage.json
something like this:"scripts": { "lint": "npm run eslint && npm run prettier -- --check", "format": "npm run eslint -- --fix && npm run prettier -- --write", "prettier": "prettier \"src/**/*.ts\" \"src/**/*.js\" \"src/**/*.html\"", "eslint": "eslint \"src/**/*.ts\" \"src/**/*.js\" \"src/**/*.html\"", }
npm run lint
: for checking if ESLint and Prettier complainnpm run format
: attempt to autofix lint issues and autoformat code
📝 Not every rule in this configuration is autofixable, so
npm run format
may continue failing until lint issues are addressed manually.
⚠️ REVIEW THIS SECTION
- Follow the same strategy as Ionic
eslint-config
- Or, use
lint-staged
as suggested by PrettierProbably we should use
lint-staged
as we're already using that in other projects.