Feature request: rulesdir option in .eslintrc
See original GitHub issueI’m using sublime-eslint as well as the CLI itself where I use --rulesdir
. sublime-eslint does allow CLI switches, but only on a global basis, not per-project (which I think is more of an SublimeLinter issue). This presents the problem that sublime-eslint would fail on line 1 of every file because of the custom rule being present in .eslintrc
.
Ideally, I think every CLI options should have a counterpart in .eslintrc
to enable full portability, with CLI options taking precedence if both are present.
Another alternative I could see is to not hard-fail when a custom rule isn’t found, and continue with the other rules present, but it surely isn’t optimal.
Issue Analytics
- State:
- Created 8 years ago
- Comments:36 (34 by maintainers)
Top Results From Across the Web
Configuring ESLint - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Command Line Interface
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Configuration Files - ESLint - Pluggable JavaScript Linter
The second way to use configuration files is to save the file wherever you would like and pass its location to the CLI...
Read more >ESLint's new config system, Part 2: Introduction to flat config
cjs files - With eslintrc, ESLint only ever searched for .js files when you passed a directory name on the command line, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zertosh Assuming you know which proposal we want to focus on, you may certainly create the issue. (I haven’t been following closely and am also not TSC, but I can at least assure you that the TSC does not need to drive the new issue creation.)
I would like to revive this issue in light of “Breaking: New Linter API” https://github.com/eslint/eslint/pull/8465 and the current state of loading plugins by path (https://github.com/eslint/eslint/issues/3458).
--rulesdir
is a great approach for project specific rules. It’s used by ESLint (link), Node (link), and extensively at Facebook. Unfortunately,--rulesdir
is only available as a flag, and not something that can be specified in an.eslintrc
. This means that running a plaineslint
command doesn’t fully work. So IDEs and tooling don’t work without additional per-project configuration on the part of the user.The way we’ve dealt with this at Facebook is by using a js configuration that uses private APIs to simulate what
--rulesdir
does:In ESLint v4, this won’t work anymore due to https://github.com/eslint/eslint/pull/8465.
The proposed alternative to
--rulesdir
is plugins. But that has its own set of (harder) problems. For one, they must be innode_modules
-npm link
andfile://
create other problems, if anyone is interested, I’ll delve into them. The idea of loading plugins by path would solve the--rulesdir
use case, but that discussion is stalled. I don’t think that problem is solvable given the requirement that it addresses name collisions.This discussion was ended with:
I would argue that those problems are no different from say having a typo in your
eslintrc
. It’s part of your own custom setup, so it’s on you to fix it. I’d even go as far as to say that being able to override a native rule is a feature, and not a bug.I’m really concerned about what I’m going to do roll out ESLint v4 internally at Facebook, if we can’t make plain
eslint
commands just work on projects with custom rules. I’d really like arulesDir
config that has the same status asroot
(only available in local configs). If this is something that would be acceptable, I can submit PR.