I have created a custom ESLint plugin without publishing it, as I really need it for that project only.
I just created it in a folder inside my project as I only want to use it internally, nor I think I need to create a new repo for it.
Issue is that it prevents npm ci
or npm i
to properly install deps on CI, while I have no problems locally.
Here is the error I get from CI
$ npm ci && npm run build:mfe
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /builds/teleoptometry/telo-ui/node_modules/eslint-plugin-telo/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/builds/teleoptometry/telo-ui/node_modules/eslint-plugin-telo/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-07-14T10_31_53_477Z-debug.log
Here is what I have.
// .eslintrc.js
module.exports = {
extends: ['react-app'],
plugins: ['react-hooks', 'telo'], <--- telo is my plugin name
rules: {
[...other rules...]
'telo/use-telo-navigate': 'error', <--- my ryle
},
}
// package.json
"devDependencies": {
"eslint-plugin-telo": "file:./eslint"
}
My eslint folder is as follows
// my ./src/eslint/index.js file just imports the rule
module.exports = {
rules: { 'use-telo-navigate': require('./rules/use-telo-navigate') },
}
I think the issue is in the way I link the eslint plugin in package.json
, but I cannot understand why it works on my machine.
I guess I should try to extract eslint plugin in a new repo (unfortunaly I am not using a monorepo) and import it with npm link
or something, but I would like to avoid it.
I would expect my setup to be working as is, what am I doing wrong?
I found my mistake.
ESLint does not allow anymore to plug rules at runtime from a dir or file as it was with --rulesDir
argument. It must be a package. See this GitHub discussion.
So my fix was to just run cd ./eslint && npm init -y
, that is to create a package.json
file alongside the index.js
file
BTW, there are plugins to allow old --rulesDir
behavior, see for example eslint-plugin-local-rules and eslint-plugin-rulesdir