Skip to content

Commit

Permalink
feat: remove deprecated rules (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous authored Nov 26, 2019
1 parent 5f7e583 commit 7b9cc9d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
1 change: 0 additions & 1 deletion rules/core/possible-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module.exports = {
"no-unsafe-negation": "error",
"require-atomic-updates": "error",
"use-isnan": "error",
"valid-jsdoc": "off",
"valid-typeof": "error",
},
};
1 change: 0 additions & 1 deletion rules/core/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ module.exports = {
"padding-line-between-statements": "off",
"prefer-exponentiation-operator": "warn",
"prefer-object-spread": "error",
"require-jsdoc": "off",
"sort-keys": "off",
"sort-vars": "off",
"spaced-comment": "error",
Expand Down
1 change: 0 additions & 1 deletion rules/core/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const restrictedGlobals = require("eslint-restricted-globals");
module.exports = {
rules: {
"init-declarations": "off",
"no-catch-shadow": "error",
"no-delete-var": "error",
"no-label-var": "error",
"no-restricted-globals": ["error", "isFinite", "isNaN", "alert"].concat(restrictedGlobals),
Expand Down
48 changes: 48 additions & 0 deletions test/check-rules.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { EOL } = require("os");
const test = require("tape");
const { $, lintConfigFiles } = require("./helper");

const checkRules = (file, option, env = {}) => {
try {
$("eslint-find-rules", option, file, { env });
} catch (err) {
const { stdout, stderr } = err;
if (typeof stdout === "string" && stdout !== "") {
process.stderr.write(stdout + EOL);
}
if (typeof stderr === "string" && stderr !== "") {
process.stderr.write(stderr + EOL);
}
throw err;
}
};

test("no unused rules", t => {
lintConfigFiles.forEach(file => {
checkRules(file, "--unused");
t.pass(file);
});
t.end();
});

test("deprecated rules", t => {
lintConfigFiles.forEach(file => {
try {
checkRules(file, "--deprecated", { ESLINT_CONFIG_PRETTIER_NO_DEPRECATED: "true" });
} catch (err) {
if (typeof err.stdout === "string" && err.stdout.includes("jsx-a11y/label-has-for")) {
[
"",
"NOTE: `jsx-a11y/label-has-for` rule is deprecated but included in the recommended config.",
"",
"See https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md",
"",
].forEach(line => process.stdout.write(line + EOL));
} else {
throw err;
}
}
t.pass(file);
});
t.end();
});
7 changes: 5 additions & 2 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const log = msg => {
}
};

// eslint-disable-next-line max-statements
const $ = (cmd, ...args) => {
log(`> ${cmd} '${args.join("' '")}'`);
const { stdout } = execa.sync(cmd, args);
const cmdArgs = args.filter(arg => typeof arg === "string");
const options = args.find(arg => typeof arg === "object" && arg !== null) || {};
log(`> ${cmd} '${cmdArgs.join("' '")}'`);
const { stdout } = execa.sync(cmd, cmdArgs, options);
const maxLines = 20;
const lines = stdout.split(EOL);
if (lines.length < maxLines) {
Expand Down
10 changes: 0 additions & 10 deletions test/no-unused-rules.test.js

This file was deleted.

0 comments on commit 7b9cc9d

Please sign in to comment.