Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Ensuring eslint:recommended rules are sorted. #8106

Merged
merged 2 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ target.checkRuleFiles = function() {

echo("Validating rules");

const eslintConf = require("./conf/eslint.json").rules;
const eslintRecommended = require("./conf/eslint-recommended").rules;

const ruleFiles = find("lib/rules/").filter(fileType("js"));
let errors = 0;
Expand All @@ -772,12 +772,12 @@ target.checkRuleFiles = function() {
const docFilename = `docs/rules/${basename}.md`;

/**
* Check if basename is present in eslint conf
* Check if basename is present in eslint:recommended configuration.
* @returns {boolean} true if present
* @private
*/
function isInConfig() {
return eslintConf.hasOwnProperty(basename);
return eslintRecommended.hasOwnProperty(basename);
}

/**
Expand Down Expand Up @@ -810,9 +810,9 @@ target.checkRuleFiles = function() {
}
}

// check for default configuration
// check for recommended configuration
if (!isInConfig()) {
console.error("Missing default setting for %s in conf/eslint.json", basename);
console.error("Missing eslint:recommended setting for %s in conf/eslint-recommendd.js", basename);
errors++;
}

Expand Down
156 changes: 85 additions & 71 deletions conf/eslint.json → conf/eslint-recommended.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,81 @@
{
"parser": "espree",
"ecmaFeatures": {},
"rules": {
/**
* @fileoverview Configuration applied when a user configuration extends from
* eslint:recommended.
* @author Nicholas C. Zakas
*/

"use strict";

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

module.exports = {
parser: "espree",
ecmaFeatures: {},

rules: {

/* eslint-enable sort-keys */
"accessor-pairs": "off",
"array-bracket-spacing": "off",
"array-callback-return": "off",
"arrow-body-style": "off",
"arrow-parens": "off",
"arrow-spacing": "off",
"block-scoped-var": "off",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"complexity": "off",
"computed-property-spacing": "off",
"consistent-return": "off",
"consistent-this": "off",
"constructor-super": "error",
"curly": "off",
"default-case": "off",
"dot-location": "off",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
"func-call-spacing": "off",
"func-name-matching": "off",
"func-names": "off",
"func-style": "off",
"generator-star-spacing": "off",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "off",
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": "off",
"lines-around-comment": "off",
"lines-around-directive": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "off",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-cap": "off",
"new-parens": "off",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "off",
"no-array-constructor": "off",
"no-await-in-loop": "off",
Expand Down Expand Up @@ -100,20 +174,20 @@
"no-sequences": "off",
"no-shadow": "off",
"no-shadow-restricted-names": "off",
"no-whitespace-before-property": "off",
"no-spaced-func": "off",
"no-sparse-arrays": "error",
"no-sync": "off",
"no-tabs": "off",
"no-template-curly-in-string": "off",
"no-ternary": "off",
"no-trailing-spaces": "off",
"no-this-before-super": "error",
"no-throw-literal": "off",
"no-trailing-spaces": "off",
"no-undef": "error",
"no-undef-init": "off",
"no-undefined": "off",
"no-unexpected-multiline": "error",
"no-underscore-dangle": "off",
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "off",
"no-unneeded-ternary": "off",
"no-unreachable": "error",
Expand All @@ -130,70 +204,11 @@
"no-useless-escape": "off",
"no-useless-rename": "off",
"no-useless-return": "off",
"no-void": "off",
"no-var": "off",
"no-void": "off",
"no-warning-comments": "off",
"no-whitespace-before-property": "off",
"no-with": "off",
"array-bracket-spacing": "off",
"array-callback-return": "off",
"arrow-body-style": "off",
"arrow-parens": "off",
"arrow-spacing": "off",
"accessor-pairs": "off",
"block-scoped-var": "off",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"complexity": "off",
"computed-property-spacing": "off",
"consistent-return": "off",
"consistent-this": "off",
"constructor-super": "error",
"curly": "off",
"default-case": "off",
"dot-location": "off",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
"func-call-spacing": "off",
"func-names": "off",
"func-name-matching": "off",
"func-style": "off",
"generator-star-spacing": "off",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "off",
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": "off",
"line-comment-position": "off",
"lines-around-comment": "off",
"lines-around-directive": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "off",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-cap": "off",
"new-parens": "off",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"object-curly-newline": "off",
"object-curly-spacing": ["off", "never"],
"object-property-newline": "off",
Expand Down Expand Up @@ -221,8 +236,8 @@
"rest-spread-spacing": "off",
"semi": "off",
"semi-spacing": "off",
"sort-keys": "off",
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
Expand All @@ -241,8 +256,7 @@
"vars-on-top": "off",
"wrap-iife": "off",
"wrap-regex": "off",
"no-template-curly-in-string": "off",
"yield-star-spacing": "off",
"yoda": "off"
}
}
};
5 changes: 3 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ class Config {
}

/**
* Build a config object merging the base config (conf/eslint.json), the
* environments config (conf/environments.js) and eventually the user config.
* Build a config object merging the base config (conf/eslint-recommended),
* the environments config (conf/environments.js) and eventually the user
* config.
* @param {string} filePath a file in whose directory we start looking for a local config
* @returns {Object} config object
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/config/autoconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const lodash = require("lodash"),
eslint = require("../eslint"),
configRule = require("./config-rule"),
ConfigOps = require("./config-ops"),
recConfig = require("../../conf/eslint.json");
recConfig = require("../../conf/eslint-recommended");

const debug = require("debug")("eslint:autoconfig");

Expand Down
8 changes: 4 additions & 4 deletions lib/config/config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const fs = require("fs"),
stripBom = require("strip-bom"),
stripComments = require("strip-json-comments"),
stringify = require("json-stable-stringify"),
defaultOptions = require("../../conf/eslint.json"),
defaultOptions = require("../../conf/eslint-recommended"),
requireUncached = require("require-uncached");

const debug = require("debug")("eslint:config-file");
Expand Down Expand Up @@ -364,10 +364,10 @@ function applyExtends(config, filePath, relativeTo) {
if (parentPath === "eslint:recommended") {

/*
* Add an explicit substitution for eslint:recommended to conf/eslint.json
* this lets us use the eslint.json file as the recommended rules
* Add an explicit substitution for eslint:recommended to
* conf/eslint-recommended.js.
*/
parentPath = path.resolve(__dirname, "../../conf/eslint.json");
parentPath = path.resolve(__dirname, "../../conf/eslint-recommended.js");
} else if (parentPath === "eslint:all") {

/*
Expand Down
2 changes: 1 addition & 1 deletion lib/config/config-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const util = require("util"),
ConfigOps = require("./config-ops"),
getSourceCodeOfFiles = require("../util/source-code-util").getSourceCodeOfFiles,
npmUtil = require("../util/npm-util"),
recConfig = require("../../conf/eslint.json"),
recConfig = require("../../conf/eslint-recommended"),
log = require("../logging");

const debug = require("debug")("eslint:config-initializer");
Expand Down
4 changes: 2 additions & 2 deletions lib/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const assert = require("assert"),
escope = require("escope"),
levn = require("levn"),
blankScriptAST = require("../conf/blank-script.json"),
DEFAULT_PARSER = require("../conf/eslint.json").parser,
DEFAULT_PARSER = require("../conf/eslint-recommended").parser,
replacements = require("../conf/replacements.json"),
CodePathAnalyzer = require("./code-path-analysis/code-path-analyzer"),
ConfigOps = require("./config/config-ops"),
Expand Down Expand Up @@ -1192,7 +1192,7 @@ module.exports = (function() {
* @returns {Object} Object mapping rule IDs to their default configurations
*/
api.defaults = function() {
return require("../conf/eslint.json");
return require("../conf/eslint-recommended");
};

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/bench.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var eslint = require("../../lib/eslint"),
fs = require("fs");

var config = require("../../conf/eslint.json");
var config = require("../../conf/eslint-recommended");

var large = fs.readFileSync(__dirname + "/large.js", "utf8"),
medium = fs.readFileSync(__dirname + "/medium.js", "utf8"),
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config-file/js/.eslintrc.parser3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var defaultOptions = require("../../../../conf/eslint.json");
var defaultOptions = require("../../../../conf/eslint-recommended");

module.exports = {
parser: defaultOptions.parser,
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ describe("cli", () => {
getFixturePath("globals-node.js")
];

cli.execute(`--no-eslintrc --config ./conf/eslint.json --no-ignore ${files.join(" ")}`);
cli.execute(`--no-eslintrc --config ./conf/eslint-recommended.js --no-ignore ${files.join(" ")}`);

assert.equal(log.info.args[0][0].split("\n").length, 11);
});
Expand Down