Skip to content

Commit

Permalink
fix(node): remove core Node.js rules (#678)
Browse files Browse the repository at this point in the history
The Node.js rules included in ESLint core was deprecated with ESLint v7.
See https://eslint.org/docs/user-guide/migrating-to-7.0.0#deprecate-node-rules
  • Loading branch information
ybiquitous authored Jun 29, 2020
1 parent 62dc0da commit 920e80b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
"./rules/core/variables.js",
"./rules/core/styles.js",
"./rules/core/es6.js",
"./rules/core/node.js",
"./rules/plugins/prettier.js",
"./rules/plugins/eslint-comments.js",
"./rules/plugins/import.js",
Expand Down
19 changes: 0 additions & 19 deletions rules/core/node.js

This file was deleted.

46 changes: 36 additions & 10 deletions test/check-rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { $, lintConfigFiles } = require("./helper");

const checkRules = (file, option, env = {}) => {
try {
$("eslint-find-rules", option, file, { env });
$("eslint-find-rules", "--verbose", option, file, { env });
} catch (err) {
const { stdout, stderr } = err;
if (typeof stdout === "string" && stdout !== "") {
Expand All @@ -18,8 +18,37 @@ const checkRules = (file, option, env = {}) => {
};

test("no unused rules", (t) => {
const deprecatedRules = [
// NOTE: Node-specific rules are deprecated and will be removed.
// See https://eslint.org/docs/user-guide/migrating-to-7.0.0#deprecate-node-rules
"callback-return",
"global-require",
"handle-callback-err",
"no-buffer-constructor",
"no-mixed-requires",
"no-new-require",
"no-path-concat",
"no-process-env",
"no-process-exit",
"no-restricted-modules",
"no-sync",
];

lintConfigFiles.forEach((file) => {
checkRules(file, "--unused");
try {
checkRules(file, "--unused");
} catch (err) {
if (typeof err.stdout === "string") {
const msgs = deprecatedRules
.filter((rule) => err.stdout.includes(`${rule} `))
.map((rule) => ` --> "${rule}" is deprecated`);
if (msgs.length !== 0) {
process.stderr.write(msgs.join(EOL) + EOL);
return;
}
}
throw err;
}
t.pass(file);
});
t.end();
Expand All @@ -38,14 +67,11 @@ test("deprecated rules", (t) => {
checkRules(file, "--deprecated", { ESLINT_CONFIG_PRETTIER_NO_DEPRECATED: "true" });
} catch (err) {
if (typeof err.stdout === "string") {
const msg = ignoredRules
.filter((rule) => err.stdout.includes(rule))
.map(
(rule) => ` => "${rule}" is deprecated but included in the recommended config${EOL}`
)
.join("");
if (msg) {
process.stderr.write(msg);
const msgs = ignoredRules
.filter((rule) => err.stdout.includes(`${rule} `))
.map((rule) => ` --> "${rule}" is deprecated but included in the recommended config`);
if (msgs.length !== 0) {
process.stderr.write(msgs.join(EOL) + EOL);
return;
}
}
Expand Down

0 comments on commit 920e80b

Please sign in to comment.