Skip to content

Commit

Permalink
chore: switch to eslint-plugin-node's maintained fork (#16150)
Browse files Browse the repository at this point in the history
* chore: switch to eslint-plugin-n

* fixup! fix linting errors
  • Loading branch information
aladdin-add committed Jul 20, 2022
1 parent 97b95c0 commit 1233bee
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 90 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Expand Up @@ -122,23 +122,23 @@ module.exports = {
files: ["lib/*"],
excludedFiles: ["lib/unsupported-api.js"],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns()
]]
}
},
{
files: [INTERNAL_FILES.CLI_ENGINE_PATTERN],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN)
]]
}
},
{
files: [INTERNAL_FILES.LINTER_PATTERN],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN),
"fs",
resolveAbsolutePath("lib/cli-engine/index.js"),
Expand All @@ -149,7 +149,7 @@ module.exports = {
{
files: [INTERNAL_FILES.RULES_PATTERN],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN),
"fs",
resolveAbsolutePath("lib/cli-engine/index.js"),
Expand All @@ -162,7 +162,7 @@ module.exports = {
{
files: ["lib/shared/**/*"],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(),
resolveAbsolutePath("lib/cli-engine/index.js"),
resolveAbsolutePath("lib/linter/index.js"),
Expand All @@ -174,7 +174,7 @@ module.exports = {
{
files: [INTERNAL_FILES.SOURCE_CODE_PATTERN],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN),
"fs",
resolveAbsolutePath("lib/cli-engine/index.js"),
Expand All @@ -187,7 +187,7 @@ module.exports = {
{
files: [INTERNAL_FILES.RULE_TESTER_PATTERN],
rules: {
"node/no-restricted-require": ["error", [
"n/no-restricted-require": ["error", [
...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN),
resolveAbsolutePath("lib/cli-engine/index.js")
]]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -105,7 +105,7 @@
"eslint-plugin-eslint-plugin": "^4.4.0",
"eslint-plugin-internal-rules": "file:tools/internal-rules",
"eslint-plugin-jsdoc": "^38.1.6",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-unicorn": "^42.0.0",
"eslint-release": "^3.2.0",
"eslump": "^3.0.0",
Expand Down
181 changes: 111 additions & 70 deletions packages/eslint-config-eslint/default.yml
@@ -1,7 +1,7 @@
reportUnusedDisableDirectives: true
extends:
- "eslint:recommended"
- "plugin:node/recommended"
- "plugin:n/recommended"
- "plugin:jsdoc/recommended"
- "plugin:eslint-comments/recommended"
plugins:
Expand All @@ -14,34 +14,34 @@ settings:
class: "constructor"
preferredTypes:
"*":
message: "Use a more precise type or if necessary use `any` or `ArbitraryCallbackResult`"
replacement: "any"
message: "Use a more precise type or if necessary use `any` or `ArbitraryCallbackResult`"
replacement: "any"
Any:
message: "Use a more precise type or if necessary use `any` or `ArbitraryCallbackResult`"
replacement: "any"
message: "Use a more precise type or if necessary use `any` or `ArbitraryCallbackResult`"
replacement: "any"
# Function:
# message: "Point to a `@callback` namepath or `GenericCallback` if truly arbitrary in form"
# replacement: "GenericCallback"
# function:
# message: "Point to a `@callback` namepath or `GenericCallback` if truly arbitrary in form"
# replacement: "GenericCallback"
function:
message: "Point to a `@callback` namepath or `Function` if truly arbitrary in form"
replacement: "Function"
message: "Point to a `@callback` namepath or `Function` if truly arbitrary in form"
replacement: "Function"
Promise:
message: "Specify the specific Promise type, including, if necessary, the type `any`"
message: "Specify the specific Promise type, including, if necessary, the type `any`"
".<>":
message: "Prefer type form without dot"
replacement: "<>"
message: "Prefer type form without dot"
replacement: "<>"
# Object:
# message: "Use the specific object type or `PlainObject` if truly arbitrary"
# replacement: "PlainObject"
# object:
# message: "Use the specific object type or `PlainObject` if truly arbitrary"
# replacement: "PlainObject"
object:
message: "Use the specific object type or `Object` if truly arbitrary"
replacement: "Object"
message: "Use the specific object type or `Object` if truly arbitrary"
replacement: "Object"
# Array:
# message: "Use the specific array type or `GenericArray` if it is truly arbitrary."
# replacement: "GenericArray"
Expand All @@ -56,7 +56,7 @@ rules:
arrow-body-style: ["error", "as-needed"]
arrow-parens: ["error", "as-needed"]
arrow-spacing: "error"
indent: ["error", 4, {SwitchCase: 1}]
indent: ["error", 4, { SwitchCase: 1 }]
block-spacing: "error"
brace-style: ["error", "1tbs"]
camelcase: "error"
Expand Down Expand Up @@ -101,9 +101,21 @@ rules:
jsdoc/require-description: ["error", { checkConstructors: false }]
# jsdoc/require-file-overview: "error"
jsdoc/require-hyphen-before-param-description: ["error", "never"]
jsdoc/require-returns: ["error", { forceRequireReturn: true, forceReturnsWithAsync: true }]
jsdoc/require-returns:
["error", { forceRequireReturn: true, forceReturnsWithAsync: true }]
jsdoc/require-throws: "error"
jsdoc/tag-lines: ["error", "never", { tags: { example: { lines: "always" }, fileoverview: { lines: "any" } } }]
jsdoc/tag-lines:
[
"error",
"never",
{
tags:
{
example: { lines: "always" },
fileoverview: { lines: "any" },
},
},
]

# jsdoc: disable recommended rules
jsdoc/no-undefined-types: "off"
Expand All @@ -120,7 +132,7 @@ rules:
jsdoc/implements-on-classes: "error"
jsdoc/multiline-blocks: "error"
jsdoc/no-multi-asterisks: "error"
jsdoc/require-jsdoc: ["error", { require: {ClassDeclaration: true} }]
jsdoc/require-jsdoc: ["error", { require: { ClassDeclaration: true } }]
jsdoc/require-param: "error"
jsdoc/require-param-description: "error"
jsdoc/require-param-name: "error"
Expand All @@ -137,19 +149,28 @@ rules:

key-spacing: ["error", { beforeColon: false, afterColon: true }]
keyword-spacing: "error"
lines-around-comment: ["error", {
beforeBlockComment: true,
afterBlockComment: false,
beforeLineComment: true,
afterLineComment: false
}]
max-len: ["error", 160, {
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}]
lines-around-comment:
[
"error",
{
beforeBlockComment: true,
afterBlockComment: false,
beforeLineComment: true,
afterLineComment: false,
},
]
max-len:
[
"error",
160,
{
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true,
},
]
max-statements-per-line: "error"
new-cap: "error"
new-parens: "error"
Expand All @@ -175,7 +196,7 @@ rules:
no-mixed-spaces-and-tabs: ["error", false] # Modified from recommended
no-multi-spaces: "error"
no-multi-str: "error"
no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0, maxEOF: 0}]
no-multiple-empty-lines: ["error", { max: 2, maxBOF: 0, maxEOF: 0 }]
no-nested-ternary: "error"
no-new: "error"
no-new-func: "error"
Expand All @@ -185,15 +206,35 @@ rules:
no-param-reassign: "error"
no-proto: "error"
no-process-exit: "off"
no-restricted-properties: [
"error",
{ property: "substring", message: "Use .slice instead of .substring." },
{ property: "substr", message: "Use .slice instead of .substr." },
{ object: "assert", property: "equal", message: "Use assert.strictEqual instead of assert.equal." },
{ object: "assert", property: "notEqual", message: "Use assert.notStrictEqual instead of assert.notEqual." },
{ object: "assert", property: "deepEqual", message: "Use assert.deepStrictEqual instead of assert.deepEqual." },
{ object: "assert", property: "notDeepEqual", message: "Use assert.notDeepStrictEqual instead of assert.notDeepEqual." }
]
no-restricted-properties:
[
"error",
{
property: "substring",
message: "Use .slice instead of .substring.",
},
{ property: "substr", message: "Use .slice instead of .substr." },
{
object: "assert",
property: "equal",
message: "Use assert.strictEqual instead of assert.equal.",
},
{
object: "assert",
property: "notEqual",
message: "Use assert.notStrictEqual instead of assert.notEqual.",
},
{
object: "assert",
property: "deepEqual",
message: "Use assert.deepStrictEqual instead of assert.deepEqual.",
},
{
object: "assert",
property: "notDeepEqual",
message: "Use assert.notDeepStrictEqual instead of assert.notDeepEqual.",
},
]
no-return-assign: "error"
no-script-url: "error"
no-self-compare: "error"
Expand All @@ -202,15 +243,18 @@ rules:
no-tabs: "error"
no-throw-literal: "error"
no-trailing-spaces: "error"
no-undef: ["error", {typeof: true}] # Modified from recommended
no-undef: ["error", { typeof: true }] # Modified from recommended
no-undef-init: "error"
no-undefined: "error"
no-underscore-dangle: ["error", {allowAfterThis: true}]
no-underscore-dangle: ["error", { allowAfterThis: true }]
no-unmodified-loop-condition: "error"
no-unneeded-ternary: "error"
no-unreachable-loop: "error"
no-unused-expressions: "error"
no-unused-vars: ["error", {vars: "all", args: "after-used", caughtErrors: "all"}] # Modified from recommended
no-unused-vars: [
"error",
{ vars: "all", args: "after-used", caughtErrors: "all" },
] # Modified from recommended
no-use-before-define: "error"
no-useless-call: "error"
no-useless-computed-key: "error"
Expand All @@ -221,12 +265,12 @@ rules:
no-whitespace-before-property: "error"
no-var: "error"

node/callback-return: ["error", ["cb", "callback", "next"]]
node/handle-callback-err: ["error", "err"]
node/no-deprecated-api: "error"
node/no-mixed-requires: "error"
node/no-new-require: "error"
node/no-path-concat: "error"
n/callback-return: ["error", ["cb", "callback", "next"]]
n/handle-callback-err: ["error", "err"]
n/no-deprecated-api: "error"
n/no-mixed-requires: "error"
n/no-new-require: "error"
n/no-path-concat: "error"

object-curly-newline: ["error", { "consistent": true, "multiline": true }]
object-curly-spacing: ["error", "always"]
Expand All @@ -235,19 +279,16 @@ rules:
one-var-declaration-per-line: "error"
operator-assignment: "error"
operator-linebreak: "error"
padding-line-between-statements: [
"error",
{
blankLine: "always",
prev: ["const", "let", "var"],
next: "*"
},
{
blankLine: "any",
prev: ["const", "let", "var"],
next: ["const", "let", "var"]
}
]
padding-line-between-statements:
[
"error",
{ blankLine: "always", prev: ["const", "let", "var"], next: "*" },
{
blankLine: "any",
prev: ["const", "let", "var"],
next: ["const", "let", "var"],
},
]
prefer-arrow-callback: "error"
prefer-const: "error"
prefer-exponentiation-operator: "error"
Expand All @@ -257,24 +298,24 @@ rules:
prefer-rest-params: "error"
prefer-spread: "error"
prefer-template: "error"
quotes: ["error", "double", {avoidEscape: true}]
quotes: ["error", "double", { avoidEscape: true }]
quote-props: ["error", "as-needed"]
radix: "error"
require-unicode-regexp: "error"
rest-spread-spacing: "error"
semi: "error"
semi-spacing: ["error", {before: false, after: true}]
semi-spacing: ["error", { before: false, after: true }]
semi-style: "error"
space-before-blocks: "error"
space-before-function-paren: ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}]
space-before-function-paren:
[
"error",
{ "anonymous": "never", "named": "never", "asyncArrow": "always" },
]
space-in-parens: "error"
space-infix-ops: "error"
space-unary-ops: ["error", {words: true, nonwords: false}]
spaced-comment: ["error", "always", { exceptions: ["-"]}]
space-unary-ops: ["error", { words: true, nonwords: false }]
spaced-comment: ["error", "always", { exceptions: ["-"] }]
strict: ["error", "global"]
switch-colon-spacing: "error"
symbol-description: "error"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-eslint/package.json
Expand Up @@ -22,7 +22,7 @@
"peerDependencies": {
"eslint-plugin-eslint-comments": ">=3.2.0",
"eslint-plugin-jsdoc": ">=38.1.6",
"eslint-plugin-node": ">=11.1.0",
"eslint-plugin-n": ">=15.2.4",
"eslint-plugin-unicorn": ">=42.0.0"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion tests/_utils/test-lazy-loading-rules.js
Expand Up @@ -62,5 +62,5 @@ addHook(
await eslint.lintFiles([pattern]);
})().catch(({ message, stack }) => {
process.send({ message, stack });
process.exit(1);
process.exit(1); // eslint-disable-line n/no-process-exit -- this is a child process
});

0 comments on commit 1233bee

Please sign in to comment.