forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 49
feat: add config "flat/all" #401
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
Merged
+137
−69
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
df17858
feat: add config "flat/all"
aladdin-add ef440cc
chore: add tests for flat configs
aladdin-add 09ef496
docs: add docs for config `flat/all`
aladdin-add d13d72a
refactor: replace individual rules with allRules in base configuration
aladdin-add 0d8cc54
fix: do not use ts-ignore
aladdin-add 41bbbed
docs: run eslint-doc-generator
aladdin-add 04cfb75
fix: add no-top-level-await
aladdin-add File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @fileoverview All rules in the plugin. | ||
* @author aladdin-add<[email protected]> | ||
* TODO: maybe auto-generated in the future? | ||
*/ | ||
"use strict" | ||
|
||
/** @import { Rule } from 'eslint' */ | ||
|
||
/** @type {Record<string, Rule.RuleModule> } */ | ||
module.exports = { | ||
"callback-return": require("./rules/callback-return"), | ||
"exports-style": require("./rules/exports-style"), | ||
"file-extension-in-import": require("./rules/file-extension-in-import"), | ||
"global-require": require("./rules/global-require"), | ||
"handle-callback-err": require("./rules/handle-callback-err"), | ||
"no-callback-literal": require("./rules/no-callback-literal"), | ||
"no-deprecated-api": require("./rules/no-deprecated-api"), | ||
"no-exports-assign": require("./rules/no-exports-assign"), | ||
"no-extraneous-import": require("./rules/no-extraneous-import"), | ||
"no-extraneous-require": require("./rules/no-extraneous-require"), | ||
"no-missing-import": require("./rules/no-missing-import"), | ||
"no-missing-require": require("./rules/no-missing-require"), | ||
"no-mixed-requires": require("./rules/no-mixed-requires"), | ||
"no-new-require": require("./rules/no-new-require"), | ||
"no-path-concat": require("./rules/no-path-concat"), | ||
"no-process-env": require("./rules/no-process-env"), | ||
"no-process-exit": require("./rules/no-process-exit"), | ||
"no-restricted-import": require("./rules/no-restricted-import"), | ||
"no-restricted-require": require("./rules/no-restricted-require"), | ||
"no-sync": require("./rules/no-sync"), | ||
"no-top-level-await": require("./rules/no-top-level-await"), | ||
"no-unpublished-bin": require("./rules/no-unpublished-bin"), | ||
"no-unpublished-import": require("./rules/no-unpublished-import"), | ||
"no-unpublished-require": require("./rules/no-unpublished-require"), | ||
"no-unsupported-features/es-builtins": require("./rules/no-unsupported-features/es-builtins"), | ||
"no-unsupported-features/es-syntax": require("./rules/no-unsupported-features/es-syntax"), | ||
"no-unsupported-features/node-builtins": require("./rules/no-unsupported-features/node-builtins"), | ||
"prefer-global/buffer": require("./rules/prefer-global/buffer"), | ||
"prefer-global/console": require("./rules/prefer-global/console"), | ||
"prefer-global/process": require("./rules/prefer-global/process"), | ||
"prefer-global/text-decoder": require("./rules/prefer-global/text-decoder"), | ||
"prefer-global/text-encoder": require("./rules/prefer-global/text-encoder"), | ||
"prefer-global/url-search-params": require("./rules/prefer-global/url-search-params"), | ||
"prefer-global/url": require("./rules/prefer-global/url"), | ||
"prefer-node-protocol": require("./rules/prefer-node-protocol"), | ||
"prefer-promises/dns": require("./rules/prefer-promises/dns"), | ||
"prefer-promises/fs": require("./rules/prefer-promises/fs"), | ||
"process-exit-as-throw": require("./rules/process-exit-as-throw"), | ||
hashbang: require("./rules/hashbang"), | ||
|
||
// Deprecated rules. | ||
"no-hide-core-modules": require("./rules/no-hide-core-modules"), | ||
shebang: require("./rules/shebang"), | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
"use strict" | ||
|
||
/** | ||
* @type {import('eslint').Linter.RulesRecord} | ||
*/ | ||
module.exports.commonRules = { | ||
"n/no-deprecated-api": "error", | ||
"n/no-extraneous-import": "error", | ||
"n/no-extraneous-require": "error", | ||
"n/no-exports-assign": "error", | ||
"n/no-missing-import": "error", | ||
"n/no-missing-require": "error", | ||
"n/no-process-exit": "error", | ||
"n/no-unpublished-bin": "error", | ||
"n/no-unpublished-import": "error", | ||
"n/no-unpublished-require": "error", | ||
"n/no-unsupported-features/es-builtins": "error", | ||
"n/no-unsupported-features/es-syntax": "error", | ||
"n/no-unsupported-features/node-builtins": "error", | ||
"n/process-exit-as-throw": "error", | ||
"n/hashbang": "error", | ||
const rules = require("../all-rules") | ||
|
||
/** @type {import('eslint').Linter.RulesRecord} */ | ||
const recommendeRulesConfig = {} | ||
|
||
/** @type {import('eslint').Linter.RulesRecord} */ | ||
const allRulesConfig = {} | ||
|
||
for (const [ruleName, rule] of Object.entries(rules)) { | ||
const scopedRuleName = `n/${ruleName}` | ||
// only non-deprecated rules | ||
if (rule.meta?.deprecated !== true) { | ||
allRulesConfig[scopedRuleName] = "error" | ||
|
||
if (rule.meta?.docs?.recommended === true) { | ||
recommendeRulesConfig[scopedRuleName] = "error" | ||
} | ||
} | ||
scagood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
exports.recommendeRulesConfig = recommendeRulesConfig | ||
exports.allRulesConfig = allRulesConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @fileoverview config for enabling all rules in the plugin. | ||
* @author aladdin-add<[email protected]>SS | ||
*/ | ||
"use strict" | ||
|
||
const { allRulesConfig } = require("./_commons") | ||
const recommendeConfig = require("./recommended") | ||
|
||
/** | ||
* https://eslint.org/docs/latest/use/configure/configuration-files-new | ||
* @type {import('eslint').Linter.FlatConfig} | ||
*/ | ||
exports.flat = { | ||
name: "node/flat/all", | ||
languageOptions: recommendeConfig.flat.languageOptions ?? {}, | ||
rules: allRulesConfig, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict" | ||
|
||
const assert = require("assert") | ||
const pkg = require("eslint-plugin-n") | ||
|
||
describe("flat configs", () => { | ||
it("should correctly export the plugin", () => { | ||
assert.strictEqual(typeof pkg, "object") | ||
assert.strictEqual(pkg.meta.name, "eslint-plugin-n") | ||
assert(pkg.configs) | ||
assert(pkg.rules) | ||
}) | ||
|
||
it("should export flat/recommended-module", () => { | ||
const config = pkg.configs["flat/recommended-module"] | ||
assert.strictEqual(config.plugins.n, pkg) | ||
assert(config.rules, "should have rules configured") | ||
}) | ||
|
||
it("should export flat/recommeded-script", () => { | ||
const config = pkg.configs["flat/recommended-script"] | ||
assert.strictEqual(config.plugins.n, pkg) | ||
assert(config.rules, "should have rules configured") | ||
}) | ||
|
||
it("should export flat/all", () => { | ||
const config = pkg.configs["flat/all"] | ||
assert.strictEqual(config.plugins.n, pkg) | ||
assert(config.rules, "should have rules configured") | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.