cletusw / eslint-plugin-local-rules

A plugin for ESLint that allows you to use project-specific rules
MIT License
161 stars 9 forks source link

Cannot find "eslint-local-rules.{,.cjs}" #7

Closed AbdealiLoKo closed 2 years ago

AbdealiLoKo commented 3 years ago

I am using an angular project. I tried simply doing:

$ npm install eslint-plugin-local-rules --save-dev

And then added this to .eslintrc:

"plugins": [
   ...,
   "eslint-plugin-local-rules"
]

And when i now run ng lint - it gives me this error:

An unhandled exception occurred: Failed to load plugin 'eslint-plugin-local-rules' declared in '.eslintrc.json#overrides[0]': eslint-plugin-local-rules: Cannot find "eslint-local-rules.{,.cjs}(looking up from "/home/abdealijk/app/frontend/node_modules/eslint-plugin-local-rules").
cletusw commented 3 years ago

I'll fix the error text to be a little clearer, but in the meantime, have you added an eslint-local-rules.js file at the root of your project? This plugin is only for when you want ESLint to run additional rules without having to specify --rulesdir every time. See https://eslint.org/docs/developer-guide/working-with-rules#runtime-rules for more information on --rulesdir.

cletusw commented 3 years ago

Hopefully aad8528772f0baa77393e0d40b4f2f71699f7d35 helps with the error message. Let me know if you're still having trouble after creating an eslint-local-rules.js (or close this issue if that resolves it). Thanks!

AbdealiLoKo commented 3 years ago

Yes, so I have the following setup:

.
├── README.md
├── backend
│   ├── src
│   ├── package.json
│   └── eslint-local-rules
│       └── index.js
├── backend
    ├── README.md      
    ...
cletusw commented 2 years ago

@AbdealiJK Sorry for the delay -- What does the error say if you run with v1.3.0 (since the error message should now be a little clearer)? Can you post the contents of your eslint-local-rules/index.js file? Also, from which directory are you running ng lint? Thanks.

AbdealiLoKo commented 2 years ago

Hi @cletusw I couldn't get it to work earlier and so made some changes to get a different setup working Will come back to this maybe if I need to clean it up and simplify the logic - but as of now, I don't have the setup to try it out again. Feel free to close and I can come back when I try it again

cletusw commented 2 years ago

Sounds good! Sorry about that.