Skip to content

Commit 31c6f21

Browse files
committed
[eslint config] [base] [refactor] make a single source of truth for whitespace rule names
1 parent 91cab81 commit 31c6f21

File tree

3 files changed

+53
-98
lines changed

3 files changed

+53
-98
lines changed

packages/eslint-config-airbnb-base/whitespace-async.js

+2-49
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const entries = require('object.entries');
55
const { ESLint } = require('eslint');
66

77
const baseConfig = require('.');
8+
const whitespaceRules = require('./whitespaceRules');
89

910
const severities = ['off', 'warn', 'error'];
1011

@@ -45,52 +46,4 @@ async function onlyErrorOnRules(rulesToError, config) {
4546
return errorsOnly;
4647
}
4748

48-
onlyErrorOnRules([
49-
'array-bracket-newline',
50-
'array-bracket-spacing',
51-
'array-element-newline',
52-
'arrow-spacing',
53-
'block-spacing',
54-
'comma-spacing',
55-
'computed-property-spacing',
56-
'dot-location',
57-
'eol-last',
58-
'func-call-spacing',
59-
'function-paren-newline',
60-
'generator-star-spacing',
61-
'implicit-arrow-linebreak',
62-
'indent',
63-
'key-spacing',
64-
'keyword-spacing',
65-
'line-comment-position',
66-
'linebreak-style',
67-
'multiline-ternary',
68-
'newline-per-chained-call',
69-
'no-irregular-whitespace',
70-
'no-mixed-spaces-and-tabs',
71-
'no-multi-spaces',
72-
'no-regex-spaces',
73-
'no-spaced-func',
74-
'no-trailing-spaces',
75-
'no-whitespace-before-property',
76-
'nonblock-statement-body-position',
77-
'object-curly-newline',
78-
'object-curly-spacing',
79-
'object-property-newline',
80-
'one-var-declaration-per-line',
81-
'operator-linebreak',
82-
'padded-blocks',
83-
'padding-line-between-statements',
84-
'rest-spread-spacing',
85-
'semi-spacing',
86-
'semi-style',
87-
'space-before-blocks',
88-
'space-before-function-paren',
89-
'space-in-parens',
90-
'space-infix-ops',
91-
'space-unary-ops',
92-
'spaced-comment',
93-
'switch-colon-spacing',
94-
'template-tag-spacing',
95-
'import/newline-after-import',
96-
], baseConfig).then((config) => console.log(JSON.stringify(config)));
49+
onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config)));

packages/eslint-config-airbnb-base/whitespace.js

+2-49
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (CLIEngine) {
66
/* eslint no-inner-declarations: 0 */
77
const assign = require('object.assign');
88
const entries = require('object.entries');
9+
const whitespaceRules = require('./whitespaceRules');
910

1011
const baseConfig = require('.');
1112

@@ -45,55 +46,7 @@ if (CLIEngine) {
4546
return errorsOnly;
4647
}
4748

48-
module.exports = onlyErrorOnRules([
49-
'array-bracket-newline',
50-
'array-bracket-spacing',
51-
'array-element-newline',
52-
'arrow-spacing',
53-
'block-spacing',
54-
'comma-spacing',
55-
'computed-property-spacing',
56-
'dot-location',
57-
'eol-last',
58-
'func-call-spacing',
59-
'function-paren-newline',
60-
'generator-star-spacing',
61-
'implicit-arrow-linebreak',
62-
'indent',
63-
'key-spacing',
64-
'keyword-spacing',
65-
'line-comment-position',
66-
'linebreak-style',
67-
'multiline-ternary',
68-
'newline-per-chained-call',
69-
'no-irregular-whitespace',
70-
'no-mixed-spaces-and-tabs',
71-
'no-multi-spaces',
72-
'no-regex-spaces',
73-
'no-spaced-func',
74-
'no-trailing-spaces',
75-
'no-whitespace-before-property',
76-
'nonblock-statement-body-position',
77-
'object-curly-newline',
78-
'object-curly-spacing',
79-
'object-property-newline',
80-
'one-var-declaration-per-line',
81-
'operator-linebreak',
82-
'padded-blocks',
83-
'padding-line-between-statements',
84-
'rest-spread-spacing',
85-
'semi-spacing',
86-
'semi-style',
87-
'space-before-blocks',
88-
'space-before-function-paren',
89-
'space-in-parens',
90-
'space-infix-ops',
91-
'space-unary-ops',
92-
'spaced-comment',
93-
'switch-colon-spacing',
94-
'template-tag-spacing',
95-
'import/newline-after-import',
96-
], baseConfig);
49+
module.exports = onlyErrorOnRules(whitespaceRules, baseConfig);
9750
} else {
9851
const path = require('path');
9952
const { execSync } = require('child_process');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = [
2+
'array-bracket-newline',
3+
'array-bracket-spacing',
4+
'array-element-newline',
5+
'arrow-spacing',
6+
'block-spacing',
7+
'comma-spacing',
8+
'computed-property-spacing',
9+
'dot-location',
10+
'eol-last',
11+
'func-call-spacing',
12+
'function-paren-newline',
13+
'generator-star-spacing',
14+
'implicit-arrow-linebreak',
15+
'indent',
16+
'key-spacing',
17+
'keyword-spacing',
18+
'line-comment-position',
19+
'linebreak-style',
20+
'multiline-ternary',
21+
'newline-per-chained-call',
22+
'no-irregular-whitespace',
23+
'no-mixed-spaces-and-tabs',
24+
'no-multi-spaces',
25+
'no-regex-spaces',
26+
'no-spaced-func',
27+
'no-trailing-spaces',
28+
'no-whitespace-before-property',
29+
'nonblock-statement-body-position',
30+
'object-curly-newline',
31+
'object-curly-spacing',
32+
'object-property-newline',
33+
'one-var-declaration-per-line',
34+
'operator-linebreak',
35+
'padded-blocks',
36+
'padding-line-between-statements',
37+
'rest-spread-spacing',
38+
'semi-spacing',
39+
'semi-style',
40+
'space-before-blocks',
41+
'space-before-function-paren',
42+
'space-in-parens',
43+
'space-infix-ops',
44+
'space-unary-ops',
45+
'spaced-comment',
46+
'switch-colon-spacing',
47+
'template-tag-spacing',
48+
'import/newline-after-import'
49+
];

0 commit comments

Comments
 (0)