The easiest way to get linting going in in your ember project
install from npm:
npm add ember-eslint eslint
or, from source (by editing your package.json):
"devDependencies": {
"ember-eslint": "github:NullVoxPopuli/ember-eslint"
}
In eslint.config.mjs
,
import { ember } from 'ember-eslint';
export default [
...ember.recommended(import.meta.dirname),
];
In package.json
:
"scripts": {
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix"
}
And that's it!
All configs will "do the right thing" when they detect that you're using (or not using) TypeScript, V2 (Vite) projects, etc
This config mirrors the lint config that is specified in ember-cli
, and where any significant change has a Request For Comments.
import { ember } from 'ember-eslint';
export default [
...ember.recommended(import.meta.dirname),
];
This config supports a 2x2x2 matrix of features:
- TypeScript vs JavaScript
- App vs Addon
-
type=module
packages and classic packages
-
utils.hasBabelConfig
- returns true when the host environment has a babel config -
utils.hasTypescript
- returns true when the host environment has typescript -
utils.hasTypeModule
- returns true when the host environment hastype=module
in the package.json -
parsers.esm
- the parser options for JS (babel) and TS ESM files
Docs: https://eslint.org/docs/latest/use/configure/debug
Print a file's calculated configuration
npx eslint --print-config path/to/file.js
Inspecting the config
npx eslint --inspect-config