Skip to content

Commit

Permalink
Chore: remove unnecessary eslint-disable comments in codebase (#9032)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark committed Jul 29, 2017
1 parent 0f97279 commit 3141872
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 67 deletions.
25 changes: 11 additions & 14 deletions conf/eslint-recommended.js
Expand Up @@ -6,13 +6,10 @@

"use strict";

/* eslint sort-keys: ["error", "asc"], quote-props: ["error", "consistent"] */
/* eslint-disable sort-keys */
/* eslint sort-keys: ["error", "asc"] */

module.exports = {
rules: {

/* eslint-enable sort-keys */
"accessor-pairs": "off",
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
Expand All @@ -25,23 +22,23 @@ module.exports = {
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
camelcase: "off",
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"complexity": "off",
complexity: "off",
"computed-property-spacing": "off",
"consistent-return": "off",
"consistent-this": "off",
"constructor-super": "error",
"curly": "off",
curly: "off",
"default-case": "off",
"dot-location": "off",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
eqeqeq: "off",
"for-direction": "off",
"func-call-spacing": "off",
"func-name-matching": "off",
Expand All @@ -55,7 +52,7 @@ module.exports = {
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
indent: "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "off",
Expand Down Expand Up @@ -234,13 +231,13 @@ module.exports = {
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "off",
quotes: "off",
radix: "off",
"require-await": "off",
"require-jsdoc": "off",
"require-yield": "error",
"rest-spread-spacing": "off",
"semi": "off",
semi: "off",
"semi-spacing": "off",
"semi-style": "off",
"sort-imports": "off",
Expand All @@ -252,7 +249,7 @@ module.exports = {
"space-infix-ops": "off",
"space-unary-ops": "off",
"spaced-comment": "off",
"strict": "off",
strict: "off",
"switch-colon-spacing": "off",
"symbol-description": "off",
"template-curly-spacing": "off",
Expand All @@ -265,6 +262,6 @@ module.exports = {
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "off",
"yoda": "off"
yoda: "off"
}
};
4 changes: 2 additions & 2 deletions lib/config/config-file.js
Expand Up @@ -3,8 +3,6 @@
* @author Nicholas C. Zakas
*/

/* eslint no-use-before-define: 0 */

"use strict";

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -418,6 +416,8 @@ function applyExtends(config, configContext, filePath, relativeTo) {
);
}
debug(`Loading ${parentPath}`);

// eslint-disable-next-line no-use-before-define
return ConfigOps.merge(load(parentPath, configContext, relativeTo), previousValue);
} catch (e) {

Expand Down
32 changes: 12 additions & 20 deletions lib/testers/rule-tester.js
Expand Up @@ -250,7 +250,6 @@ class RuleTester {
const testerConfig = this.testerConfig,
requiredScenarios = ["valid", "invalid"],
scenarioErrors = [],
result = {},
linter = this.linter;

if (lodash.isNil(test) || typeof test !== "object") {
Expand All @@ -269,16 +268,13 @@ class RuleTester {
].concat(scenarioErrors).join("\n"));
}

/* eslint-disable no-shadow */

/**
* Run the rule for the given item
* @param {string} ruleName name of the rule
* @param {string|Object} item Item to run the rule against
* @returns {Object} Eslint run result
* @private
*/
function runRuleForItem(ruleName, item) {
function runRuleForItem(item) {
let config = lodash.cloneDeep(testerConfig),
code, filename, beforeAST, afterAST;

Expand Down Expand Up @@ -350,27 +346,27 @@ class RuleTester {

try {
linter.rules.get = function(ruleId) {
const rule = originalGet.call(linter.rules, ruleId);
const originalRule = originalGet.call(linter.rules, ruleId);

if (typeof rule === "function") {
if (typeof originalRule === "function") {
return function(context) {
Object.freeze(context);
freezeDeeply(context.options);
freezeDeeply(context.settings);
freezeDeeply(context.parserOptions);

return rule(context);
return originalRule(context);
};
}
return {
meta: rule.meta,
meta: originalRule.meta,
create(context) {
Object.freeze(context);
freezeDeeply(context.options);
freezeDeeply(context.settings);
freezeDeeply(context.parserOptions);

return rule.create(context);
return originalRule.create(context);
}
};

Expand Down Expand Up @@ -404,13 +400,12 @@ class RuleTester {
/**
* Check if the template is valid or not
* all valid cases go through this
* @param {string} ruleName name of the rule
* @param {string|Object} item Item to run the rule against
* @returns {void}
* @private
*/
function testValidTemplate(ruleName, item) {
const result = runRuleForItem(ruleName, item);
function testValidTemplate(item) {
const result = runRuleForItem(item);
const messages = result.messages;

assert.equal(messages.length, 0, util.format("Should have no errors but had %d: %s",
Expand Down Expand Up @@ -444,16 +439,15 @@ class RuleTester {
/**
* Check if the template is invalid or not
* all invalid cases go through this.
* @param {string} ruleName name of the rule
* @param {string|Object} item Item to run the rule against
* @returns {void}
* @private
*/
function testInvalidTemplate(ruleName, item) {
function testInvalidTemplate(item) {
assert.ok(item.errors || item.errors === 0,
`Did not specify errors for an invalid test of ${ruleName}`);

const result = runRuleForItem(ruleName, item);
const result = runRuleForItem(item);
const messages = result.messages;


Expand Down Expand Up @@ -543,7 +537,7 @@ class RuleTester {
test.valid.forEach(valid => {
RuleTester.it(typeof valid === "object" ? valid.code : valid, () => {
linter.defineRules(this.rules);
testValidTemplate(ruleName, valid);
testValidTemplate(valid);
});
});
});
Expand All @@ -552,13 +546,11 @@ class RuleTester {
test.invalid.forEach(invalid => {
RuleTester.it(invalid.code, () => {
linter.defineRules(this.rules);
testInvalidTemplate(ruleName, invalid);
testInvalidTemplate(invalid);
});
});
});
});

return result.suite;
}
}

Expand Down
9 changes: 4 additions & 5 deletions tests/lib/config.js
Expand Up @@ -2,7 +2,6 @@
* @fileoverview Tests for config object.
* @author Seth McLaughlin
*/
/* eslint no-undefined: "off" */
"use strict";

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -875,7 +874,7 @@ describe("Config", () => {
parserOptions: {},
env: {},
globals: {},
parser: undefined,
parser: void 0,
rules: {
"home-folder-rule": 2
}
Expand All @@ -901,7 +900,7 @@ describe("Config", () => {
parserOptions: {},
env: {},
globals: {},
parser: undefined,
parser: void 0,
rules: {
"project-level-rule": 2
}
Expand All @@ -928,7 +927,7 @@ describe("Config", () => {
parserOptions: {},
env: {},
globals: {},
parser: undefined,
parser: void 0,
rules: {
quotes: [2, "double"]
}
Expand All @@ -953,7 +952,7 @@ describe("Config", () => {
parserOptions: {},
env: {},
globals: {},
parser: undefined,
parser: void 0,
rules: {
"project-level-rule": 2,
"subfolder-level-rule": 2
Expand Down
14 changes: 2 additions & 12 deletions tests/lib/config/config-file.js
Expand Up @@ -16,6 +16,7 @@ const assert = require("chai").assert,
os = require("os"),
yaml = require("js-yaml"),
shell = require("shelljs"),
espree = require("espree"),
ConfigFile = require("../../../lib/config/config-file"),
Linter = require("../../../lib/linter"),
Config = require("../../../lib/config");
Expand Down Expand Up @@ -48,17 +49,6 @@ function getFixturePath(filepath) {
return path.resolve(__dirname, "../../fixtures/config-file", filepath);
}

/**
* Reads a JS configuration object from a string to ensure that it parses.
* Used for testing configuration file output.
* @param {string} code The code to eval.
* @returns {*} The result of the evaluation.
* @private
*/
function readJSModule(code) {
return eval(`var module = {};\n${code}`); // eslint-disable-line no-eval
}

/**
* Helper function to write configs to temp file.
* @param {Object} config Config to write out to temp file.
Expand Down Expand Up @@ -1229,7 +1219,7 @@ describe("ConfigFile", () => {
});

leche.withData([
["JavaScript", "foo.js", readJSModule],
["JavaScript", "foo.js", espree.parse],
["JSON", "bar.json", JSON.parse],
["YAML", "foo.yaml", yaml.safeLoad],
["YML", "foo.yml", yaml.safeLoad]
Expand Down
30 changes: 16 additions & 14 deletions tests/lib/util/source-code.js
Expand Up @@ -61,37 +61,39 @@ describe("SourceCode", () => {
assert.equal(sourceCode.lines[1], "bar;");
});

/* eslint-disable no-new */

it("should throw an error when called with an AST that's missing tokens", () => {

assert.throws(() => {
new SourceCode("foo;", { comments: [], loc: {}, range: [] });
}, /missing the tokens array/);
assert.throws(
() => new SourceCode("foo;", { comments: [], loc: {}, range: [] }),
/missing the tokens array/
);

});

it("should throw an error when called with an AST that's missing comments", () => {

assert.throws(() => {
new SourceCode("foo;", { tokens: [], loc: {}, range: [] });
}, /missing the comments array/);
assert.throws(
() => new SourceCode("foo;", { tokens: [], loc: {}, range: [] }),
/missing the comments array/
);

});

it("should throw an error when called with an AST that's missing location", () => {

assert.throws(() => {
new SourceCode("foo;", { comments: [], tokens: [], range: [] });
}, /missing location information/);
assert.throws(
() => new SourceCode("foo;", { comments: [], tokens: [], range: [] }),
/missing location information/
);

});

it("should throw an error when called with an AST that's missing range", () => {

assert.throws(() => {
new SourceCode("foo;", { comments: [], tokens: [], loc: {} });
}, /missing range information/);
assert.throws(
() => new SourceCode("foo;", { comments: [], tokens: [], loc: {} }),
/missing range information/
);
});

it("should store all tokens and comments sorted by range", () => {
Expand Down

0 comments on commit 3141872

Please sign in to comment.