Comments (6)
I've been thinking more about this as I think about implementing it, and I realize that eslint already warns when deprecated rules are in use. Is this feature useful enough to implement here anyway? Or should I just close the issue?
from eslint-find-rules.
I think it's still useful to get a zero/nonzero exit code based on the config files, without having to actually run eslint.
from eslint-find-rules.
Yeah, good point. I'll keep it open and work on it when I get a chance.
from eslint-find-rules.
ESLint doesn't warn when using deprecated rules in the config, only when using rules that don't exist anymore.
I've got 2 deprecated rules here: https://github.com/alexilyaev/react-es6-starter
newline-after-var
and newline-before-return
Running eslint -c .eslintrc --ignore-path .gitignore .
doesn't show me any warning.
I think an option to show currently configured deprecated rules is very useful.
We actually have no way of checking it right now
I'm doing something similar with stylelint-find-rules.
Can show configured deprecated rules.
Just tried filtering the currentRules
:
this.getCurrentDeprecatedRules = function () {
var rules = eslint.linter.getRules();
return getSortedRules(currentRules).filter(function (rule) {
return _isDeprecated(rules.get(rule) || '')
});
};
It worked, though if I have extends, it counts rules from them as well.
Perhaps ignore extends somehow.
from eslint-find-rules.
A flag to ignore a config's "extends" would be nice.
But atm, only manipulating the input (removing the "extends" property of the config to be loaded) before actually loading the configuration via ESLint's CLIEngine comes to my mind.
from eslint-find-rules.
@ta2edchimp @randycoulman So, after 2 years, I find myself back here :-)
I'm trying to validate user configured rules to not have deprecated rules.
This is useful when upgrading configs/plugins which deprecate certain rules.
Right now running eslint-find-rules -d .eslintrc
will show deprecated rules not only from user configured rules, but also from extends
.
I dug into the code and found it's not so simple to mitigate.
At _getConfigs
we use cliEngine.getConfigForFile
which loads the configFile
and merges all extends
on top of it.
Which means that currentRuleNames
will already include rules from extends and not only the user defined rules.
And then deprecatedRuleNames
can show rules that were not defined by the user.
This happened to me with eslint-config-prettier
:
prettier/eslint-config-prettier#112
I tried to dig into eslint
's CLIEngine
code as well.
Looks like there's a cascade of configs that are being loaded and merged under CascadingConfigArrayFactory
.
But eventually our configFile
is loaded with configArrayFactory.loadFile
, which runs _normalizeConfigData
, which then loads and merges the extends
and other things.
The only thing I came up with is this:
const { ConfigArrayFactory } = require('eslint/lib/cli-engine/config-array-factory.js');
const configArrayFactory = new ConfigArrayFactory();
configArrayFactory.loadFile(configFile, { name: "UserConfig" });
Which gives us an Array of configs... the user config, extends, overrides, etc.
From here it might be possible to filter out the extends and get a merged config only from user defined rules.
Here's how it looks like
[
{ name:
'UserConfig » eslint-config-ai/react » eslint-config-prettier/react',
filePath:
'/Users/alex/www/Node/Personal/eslint-config-ai/node_modules/eslint-config-prettier/react.js',
criteria: null,
env: undefined,
globals: undefined,
noInlineConfig: undefined,
parser: undefined,
parserOptions: undefined,
plugins: undefined,
processor: undefined,
reportUnusedDisableDirectives: undefined,
root: undefined,
rules:
{ 'react/jsx-child-element-spacing': 'off',
'react/jsx-closing-bracket-location': 'off',
'react/jsx-closing-tag-location': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'react/jsx-first-prop-new-line': 'off',
'react/jsx-indent': 'off',
'react/jsx-indent-props': 'off',
'react/jsx-max-props-per-line': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/jsx-props-no-multi-spaces': 'off',
'react/jsx-space-before-closing': 'off',
'react/jsx-tag-spacing': 'off',
'react/jsx-wrap-multilines': 'off' },
settings: undefined },
{ name: 'UserConfig » eslint-config-ai/react',
filePath: '/Users/alex/www/Node/Personal/eslint-config-ai/react.js',
criteria: null,
env: { es6: true },
globals: undefined,
noInlineConfig: undefined,
parser:
{ error: null,
filePath:
'/Users/alex/www/Node/Personal/eslint-config-ai/node_modules/babel-eslint/lib/index.js',
id: 'babel-eslint',
importerName: 'UserConfig » eslint-config-ai/react',
importerPath: '/Users/alex/www/Node/Personal/eslint-config-ai/react.js' },
parserOptions:
{ ecmaVersion: 6, ecmaFeatures: [Object], sourceType: 'script' },
plugins: { react: [Object], compat: [Object] },
processor: undefined,
reportUnusedDisableDirectives: undefined,
root: undefined,
rules: { 'compat/compat': 1, 'react/jsx-pascal-case': 1 },
settings: { react: [Object] } },
{ name: 'UserConfig » eslint-config-ai/react#overrides[0]',
filePath: '/Users/alex/www/Node/Personal/eslint-config-ai/react.js',
criteria:
{ includes: [Array],
excludes: null,
basePath: '/Users/alex/www/Node/Personal/eslint-config-ai' },
env: { browser: true, node: false },
globals: { process: true, module: true },
noInlineConfig: undefined,
parser: undefined,
parserOptions: { sourceType: 'module' },
plugins: undefined,
processor: undefined,
reportUnusedDisableDirectives: undefined,
root: undefined,
rules: { strict: [Array] },
settings: undefined },
{ name: 'UserConfig',
filePath: '/Users/alex/www/Node/Personal/eslint-config-ai/.eslintrc',
criteria: null,
env: undefined,
globals: undefined,
noInlineConfig: undefined,
parser: undefined,
parserOptions: undefined,
plugins: undefined,
processor: undefined,
reportUnusedDisableDirectives: undefined,
root: true,
rules: {},
settings: undefined }
]
from eslint-find-rules.
Related Issues (20)
- print as list HOT 2
- Scoped plugin error HOT 4
- eslint v6 support HOT 15
- Security warning for "mem" HOT 12
- Doesn't find unused rules in @typescript-eslint/eslint-plugin HOT 4
- Support overrides HOT 14
- eslint v7 support
- Handle typescript-eslint configuration HOT 1
- git clone error on windows HOT 6
- I'm not sure how to deal with renamed rule in ESLint 7.4.0 HOT 7
- Find unused plugin rules
- CHANGELOG missing HOT 3
- Breaks with ESLint 7.8.0 HOT 4
- Update dependencies HOT 5
- Support ESLint 8.x HOT 2
- Add support to the `rule.meta.docs.url` property to get URLs in verbose mode
- Rules in the "rules" json key are not being considered HOT 1
- No Option Provided with `--option` described in docs HOT 1
- Not able to save output as single column HOT 1
- bump `cliui` to resolve `ansi-regex` ReDoS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-find-rules.