-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(eslint): flat config support #51
base: main
Are you sure you want to change the base?
Changes from all commits
dc4b8e0
56a9dab
97b58c1
b24c6c1
d17d6b5
d667571
154179c
230c6e5
0e1fa6e
aa8c858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,21 +22,35 @@ | |
*/ | ||
"use strict"; | ||
|
||
const rules = require("./rule-list"); | ||
const rulesList = require("./rule-list"); | ||
|
||
const ruleModules = rules.reduce((map, rule) => { | ||
map[rule.ruleName] = rule.ruleModule; | ||
return map; | ||
}, {}); | ||
const allRules = {}; | ||
const recommendedRules = {}; | ||
|
||
const ruleConfigs = rules.reduce((map, rule) => { | ||
const recommended = rule.ruleModule.meta.docs.recommended; | ||
map[`@ecocode/${rule.ruleName}`] = | ||
recommended === false ? "off" : recommended; | ||
return map; | ||
}, {}); | ||
for (let { ruleName, ruleModule } of rulesList) { | ||
allRules[ruleName] = ruleModule; | ||
const { recommended } = ruleModule.meta.docs; | ||
const ruleConfiguration = recommended === false ? "off" : recommended; | ||
recommendedRules[`@ecocode/${ruleName}`] = ruleConfiguration; | ||
} | ||
|
||
module.exports = { | ||
rules: ruleModules, | ||
configs: { recommended: { plugins: ["@ecocode"], rules: ruleConfigs } }, | ||
const plugin = { | ||
meta: { | ||
name: "@ecocode/eslint-plugin", | ||
version: "1.6.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a big fan of version being hard-coded here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree not fan neither The ESLint configuration says:
So version is not mandatory and looking a other plugins, it looks like they don't include it, so we could drop it. I'll just do some check because it also says:
Even if the version is not mandatory, I would like to make sure about its impact regarding the cache feature |
||
}, | ||
rules: allRules, | ||
}; | ||
|
||
plugin.configs = { | ||
recommended: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. legacy configuration is maintained as-is no expected regressions |
||
plugins: ["@ecocode"], | ||
rules: recommendedRules, | ||
}, | ||
["flat/recommended"]: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the new flat configuration follows the plugin naming convention |
||
plugins: { "@ecocode": plugin }, | ||
rules: recommendedRules, | ||
}, | ||
}; | ||
|
||
module.exports = plugin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous implementation did 2 loops
The updated code does it only once