forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open questions: 1. need to add an equivalent eslintrc config? 2. need to add language options? fixes #400
- Loading branch information
1 parent
308c80c
commit bd7c98a
Showing
8 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,54 @@ | ||
/** | ||
* @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-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 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,26 @@ | ||
"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 = {} | ||
|
||
Object.keys(rules).map(ruleName => { | ||
const scopedRuleName = `n/${ruleName}` | ||
const rule = rules[ruleName] | ||
|
||
// only add rules that are not deprecated | ||
if (rule?.meta?.deprecated !== true) { | ||
allRulesConfig[scopedRuleName] = "error" | ||
|
||
if (rule?.meta?.docs?.recommended === true) { | ||
recommendeRulesConfig[scopedRuleName] = "error" | ||
} | ||
} | ||
}) | ||
|
||
exports.recommendeRulesConfig = recommendeRulesConfig | ||
exports.allRulesConfig = allRulesConfig |
This file contains 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,11 @@ | ||
/** | ||
* @fileoverview config for enabling all rules in the plugin. | ||
* @author aladdin-add<[email protected]>SS | ||
*/ | ||
"use strict" | ||
|
||
const { allRulesConfig } = require("./_commons") | ||
|
||
exports.flat = { | ||
rules: allRulesConfig, | ||
} |
This file contains 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 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 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 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