Skip to content

Commit 21be366

Browse files
platinumazuregyandeeps
authored andcommitted
Chore: Ensuring eslint:recommended rules are sorted. (#8106)
* Chore: Ensuring eslint:recommended rules are sorted. Also renaming to conf/eslint-recommended.js for parity with conf/eslint-all.js and ensuring references are fixed as well. * Chore: Fix Makefile message for missing eslint:recommended configuration
1 parent 360dbe4 commit 21be366

10 files changed

Lines changed: 104 additions & 89 deletions

File tree

Makefile.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ target.checkRuleFiles = function() {
762762

763763
echo("Validating rules");
764764

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

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

774774
/**
775-
* Check if basename is present in eslint conf
775+
* Check if basename is present in eslint:recommended configuration.
776776
* @returns {boolean} true if present
777777
* @private
778778
*/
779779
function isInConfig() {
780-
return eslintConf.hasOwnProperty(basename);
780+
return eslintRecommended.hasOwnProperty(basename);
781781
}
782782

783783
/**
@@ -810,9 +810,9 @@ target.checkRuleFiles = function() {
810810
}
811811
}
812812

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

Lines changed: 85 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,81 @@
1-
{
2-
"parser": "espree",
3-
"ecmaFeatures": {},
4-
"rules": {
1+
/**
2+
* @fileoverview Configuration applied when a user configuration extends from
3+
* eslint:recommended.
4+
* @author Nicholas C. Zakas
5+
*/
6+
7+
"use strict";
8+
9+
/* eslint sort-keys: ["error", "asc"], quote-props: ["error", "consistent"] */
10+
/* eslint-disable sort-keys */
11+
12+
module.exports = {
13+
parser: "espree",
14+
ecmaFeatures: {},
15+
16+
rules: {
17+
18+
/* eslint-enable sort-keys */
19+
"accessor-pairs": "off",
20+
"array-bracket-spacing": "off",
21+
"array-callback-return": "off",
22+
"arrow-body-style": "off",
23+
"arrow-parens": "off",
24+
"arrow-spacing": "off",
25+
"block-scoped-var": "off",
26+
"block-spacing": "off",
27+
"brace-style": "off",
28+
"callback-return": "off",
29+
"camelcase": "off",
30+
"capitalized-comments": "off",
31+
"class-methods-use-this": "off",
32+
"comma-dangle": "off",
33+
"comma-spacing": "off",
34+
"comma-style": "off",
35+
"complexity": "off",
36+
"computed-property-spacing": "off",
37+
"consistent-return": "off",
38+
"consistent-this": "off",
39+
"constructor-super": "error",
40+
"curly": "off",
41+
"default-case": "off",
42+
"dot-location": "off",
43+
"dot-notation": "off",
44+
"eol-last": "off",
45+
"eqeqeq": "off",
46+
"func-call-spacing": "off",
47+
"func-name-matching": "off",
48+
"func-names": "off",
49+
"func-style": "off",
50+
"generator-star-spacing": "off",
51+
"global-require": "off",
52+
"guard-for-in": "off",
53+
"handle-callback-err": "off",
54+
"id-blacklist": "off",
55+
"id-length": "off",
56+
"id-match": "off",
57+
"indent": "off",
58+
"init-declarations": "off",
59+
"jsx-quotes": "off",
60+
"key-spacing": "off",
61+
"keyword-spacing": "off",
62+
"line-comment-position": "off",
63+
"linebreak-style": "off",
64+
"lines-around-comment": "off",
65+
"lines-around-directive": "off",
66+
"max-depth": "off",
67+
"max-len": "off",
68+
"max-lines": "off",
69+
"max-nested-callbacks": "off",
70+
"max-params": "off",
71+
"max-statements": "off",
72+
"max-statements-per-line": "off",
73+
"multiline-ternary": "off",
74+
"new-cap": "off",
75+
"new-parens": "off",
76+
"newline-after-var": "off",
77+
"newline-before-return": "off",
78+
"newline-per-chained-call": "off",
579
"no-alert": "off",
680
"no-array-constructor": "off",
781
"no-await-in-loop": "off",
@@ -100,20 +174,20 @@
100174
"no-sequences": "off",
101175
"no-shadow": "off",
102176
"no-shadow-restricted-names": "off",
103-
"no-whitespace-before-property": "off",
104177
"no-spaced-func": "off",
105178
"no-sparse-arrays": "error",
106179
"no-sync": "off",
107180
"no-tabs": "off",
181+
"no-template-curly-in-string": "off",
108182
"no-ternary": "off",
109-
"no-trailing-spaces": "off",
110183
"no-this-before-super": "error",
111184
"no-throw-literal": "off",
185+
"no-trailing-spaces": "off",
112186
"no-undef": "error",
113187
"no-undef-init": "off",
114188
"no-undefined": "off",
115-
"no-unexpected-multiline": "error",
116189
"no-underscore-dangle": "off",
190+
"no-unexpected-multiline": "error",
117191
"no-unmodified-loop-condition": "off",
118192
"no-unneeded-ternary": "off",
119193
"no-unreachable": "error",
@@ -130,70 +204,11 @@
130204
"no-useless-escape": "off",
131205
"no-useless-rename": "off",
132206
"no-useless-return": "off",
133-
"no-void": "off",
134207
"no-var": "off",
208+
"no-void": "off",
135209
"no-warning-comments": "off",
210+
"no-whitespace-before-property": "off",
136211
"no-with": "off",
137-
"array-bracket-spacing": "off",
138-
"array-callback-return": "off",
139-
"arrow-body-style": "off",
140-
"arrow-parens": "off",
141-
"arrow-spacing": "off",
142-
"accessor-pairs": "off",
143-
"block-scoped-var": "off",
144-
"block-spacing": "off",
145-
"brace-style": "off",
146-
"callback-return": "off",
147-
"camelcase": "off",
148-
"capitalized-comments": "off",
149-
"class-methods-use-this": "off",
150-
"comma-dangle": "off",
151-
"comma-spacing": "off",
152-
"comma-style": "off",
153-
"complexity": "off",
154-
"computed-property-spacing": "off",
155-
"consistent-return": "off",
156-
"consistent-this": "off",
157-
"constructor-super": "error",
158-
"curly": "off",
159-
"default-case": "off",
160-
"dot-location": "off",
161-
"dot-notation": "off",
162-
"eol-last": "off",
163-
"eqeqeq": "off",
164-
"func-call-spacing": "off",
165-
"func-names": "off",
166-
"func-name-matching": "off",
167-
"func-style": "off",
168-
"generator-star-spacing": "off",
169-
"global-require": "off",
170-
"guard-for-in": "off",
171-
"handle-callback-err": "off",
172-
"id-blacklist": "off",
173-
"id-length": "off",
174-
"id-match": "off",
175-
"indent": "off",
176-
"init-declarations": "off",
177-
"jsx-quotes": "off",
178-
"key-spacing": "off",
179-
"keyword-spacing": "off",
180-
"linebreak-style": "off",
181-
"line-comment-position": "off",
182-
"lines-around-comment": "off",
183-
"lines-around-directive": "off",
184-
"max-depth": "off",
185-
"max-len": "off",
186-
"max-lines": "off",
187-
"max-nested-callbacks": "off",
188-
"max-params": "off",
189-
"max-statements": "off",
190-
"max-statements-per-line": "off",
191-
"multiline-ternary": "off",
192-
"new-cap": "off",
193-
"new-parens": "off",
194-
"newline-after-var": "off",
195-
"newline-before-return": "off",
196-
"newline-per-chained-call": "off",
197212
"object-curly-newline": "off",
198213
"object-curly-spacing": ["off", "never"],
199214
"object-property-newline": "off",
@@ -221,8 +236,8 @@
221236
"rest-spread-spacing": "off",
222237
"semi": "off",
223238
"semi-spacing": "off",
224-
"sort-keys": "off",
225239
"sort-imports": "off",
240+
"sort-keys": "off",
226241
"sort-vars": "off",
227242
"space-before-blocks": "off",
228243
"space-before-function-paren": "off",
@@ -241,8 +256,7 @@
241256
"vars-on-top": "off",
242257
"wrap-iife": "off",
243258
"wrap-regex": "off",
244-
"no-template-curly-in-string": "off",
245259
"yield-star-spacing": "off",
246260
"yoda": "off"
247261
}
248-
}
262+
};

lib/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ class Config {
234234
}
235235

236236
/**
237-
* Build a config object merging the base config (conf/eslint.json), the
238-
* environments config (conf/environments.js) and eventually the user config.
237+
* Build a config object merging the base config (conf/eslint-recommended),
238+
* the environments config (conf/environments.js) and eventually the user
239+
* config.
239240
* @param {string} filePath a file in whose directory we start looking for a local config
240241
* @returns {Object} config object
241242
*/

lib/config/autoconfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const lodash = require("lodash"),
1313
eslint = require("../eslint"),
1414
configRule = require("./config-rule"),
1515
ConfigOps = require("./config-ops"),
16-
recConfig = require("../../conf/eslint.json");
16+
recConfig = require("../../conf/eslint-recommended");
1717

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

lib/config/config-file.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const fs = require("fs"),
2323
stripBom = require("strip-bom"),
2424
stripComments = require("strip-json-comments"),
2525
stringify = require("json-stable-stringify"),
26-
defaultOptions = require("../../conf/eslint.json"),
26+
defaultOptions = require("../../conf/eslint-recommended"),
2727
requireUncached = require("require-uncached");
2828

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

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

373373
/*

lib/config/config-initializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const util = require("util"),
1717
ConfigOps = require("./config-ops"),
1818
getSourceCodeOfFiles = require("../util/source-code-util").getSourceCodeOfFiles,
1919
npmUtil = require("../util/npm-util"),
20-
recConfig = require("../../conf/eslint.json"),
20+
recConfig = require("../../conf/eslint-recommended"),
2121
log = require("../logging");
2222

2323
const debug = require("debug")("eslint:config-initializer");

lib/eslint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const assert = require("assert"),
1414
escope = require("escope"),
1515
levn = require("levn"),
1616
blankScriptAST = require("../conf/blank-script.json"),
17-
DEFAULT_PARSER = require("../conf/eslint.json").parser,
17+
DEFAULT_PARSER = require("../conf/eslint-recommended").parser,
1818
replacements = require("../conf/replacements.json"),
1919
CodePathAnalyzer = require("./code-path-analysis/code-path-analyzer"),
2020
ConfigOps = require("./config/config-ops"),
@@ -1192,7 +1192,7 @@ module.exports = (function() {
11921192
* @returns {Object} Object mapping rule IDs to their default configurations
11931193
*/
11941194
api.defaults = function() {
1195-
return require("../conf/eslint.json");
1195+
return require("../conf/eslint-recommended");
11961196
};
11971197

11981198
/**

tests/bench/bench.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var eslint = require("../../lib/eslint"),
22
fs = require("fs");
33

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

66
var large = fs.readFileSync(__dirname + "/large.js", "utf8"),
77
medium = fs.readFileSync(__dirname + "/medium.js", "utf8"),

tests/fixtures/config-file/js/.eslintrc.parser3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var defaultOptions = require("../../../../conf/eslint.json");
1+
var defaultOptions = require("../../../../conf/eslint-recommended");
22

33
module.exports = {
44
parser: defaultOptions.parser,

tests/lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ describe("cli", () => {
460460
getFixturePath("globals-node.js")
461461
];
462462

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

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

0 commit comments

Comments
 (0)