I need custom linting rules for my Ember 5.8 project. Ember 5.8 uses ESLint 8.57 and ESLint allows custom rules via Plugin, see this tutorial. Step 8 of said tutorial reads as follows:
You might want to use a locally defined plugin in one of the following scenarios:
- You want to use a plugin, but do not want to publish it to npm.
That's what I want: local, not published. But in order to make it work I had to introduce the ESLint Plugin as a local dependency to npm, which isn't mentioned in the tutorial, but described here (based on here):
{
// ...
"devDependencies": {
// ...
"eslint-plugin-acme": "file:./config/eslint"
}
}
That "works" in terms of "npm install
picks it up" and "npm run lint
works as expected".
But: It does not work for Ember: npx ember build
throws
Missing npm packages:
Package: eslint-plugin-acme
* Specified: file:./config/eslint
* Installed: (not installed)
Run `npm install` to install missing dependencies.
Stack Trace and Error Report: /tmp/error.dump.8b24e5db90b94e60ef96136863733d8a.log
An error occurred in the constructor for ember-cli-dependency-checker at /home/crusy/code/acme/frontend/node_modules/ember-cli-dependency-checker
What's the problem? Again, npm install
works, why is ember-cli-dependency-checker
recommending it?
Ok, while npm install
seemed to be happy, I had to add a package.json
to ./config/eslint
:
{
"name": "eslint-plugin-acme",
"version": "1.0.0",
"author": "crusy"
}
And link it: npm link ./config/eslint/ --save
. Now npx ember build
works as well.