Skip to content

Commit 3d6b371

Browse files
committed
Merge branch 'eslint'
2 parents d443bde + 3f624d6 commit 3d6b371

File tree

186 files changed

+1688
-1708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+1688
-1708
lines changed

.eslintrc

+26-154
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,45 @@
11
{
2+
"root": true,
3+
"extends": "airbnb-base",
24
"env": {
35
"es6": true,
46
"node": true
57
},
68
"parserOptions": {
79
"ecmaVersion": 6,
810
"ecmaFeatures": {
9-
"jsx": true
10-
}
11+
"jsx": true
12+
},
13+
"sourceType": "script",
1114
},
1215
"rules": {
13-
// Possible Errors
1416
"comma-dangle": [2, "never"],
15-
"computed-property-spacing": [2, "never"],
16-
"no-cond-assign": 2,
17-
"no-console": 2,
18-
"no-constant-condition": 2,
19-
"no-control-regex": 2,
20-
"no-debugger": 2,
21-
"no-dupe-keys": 2,
22-
"no-empty": 2,
23-
"no-empty-character-class": 2,
24-
"no-ex-assign": 2,
25-
"no-extra-boolean-cast": 2,
26-
"no-extra-parens": 0,
27-
"no-extra-semi": 2,
28-
"no-func-assign": 2,
29-
"no-inner-declarations": 2,
30-
"no-invalid-regexp": 2,
31-
"no-irregular-whitespace": 2,
32-
"no-negated-in-lhs": 2,
33-
"no-obj-calls": 2,
34-
"no-regex-spaces": 2,
35-
"no-reserved-keys": 0,
36-
"no-sparse-arrays": 2,
37-
"no-unreachable": 2,
38-
"use-isnan": 2,
39-
"valid-jsdoc": 0,
40-
"valid-typeof": 2,
41-
// Best Practices
42-
"block-scoped-var": 2,
43-
"complexity": 0,
44-
"consistent-return": 2,
45-
"curly": 2,
46-
"default-case": 2,
47-
"dot-notation": 2,
48-
"eqeqeq": 2,
49-
"guard-for-in": 2,
50-
"no-alert": 2,
51-
"no-caller": 2,
52-
"no-confusing-arrow": 2,
53-
"no-div-regex": 2,
54-
"no-else-return": 2,
55-
"no-eq-null": 2,
56-
"no-eval": 2,
57-
"no-extend-native": 2,
58-
"no-extra-bind": 2,
59-
"no-fallthrough": 2,
60-
"no-floating-decimal": 2,
61-
"no-implied-eval": 2,
62-
"no-iterator": 2,
63-
"no-labels": 2,
64-
"no-lone-blocks": 2,
65-
"no-loop-func": 2,
66-
"no-multi-spaces": 2,
67-
"no-multi-str": 2,
68-
"no-native-reassign": 2,
69-
"no-new": 2,
70-
"no-new-func": 2,
71-
"no-new-wrappers": 2,
72-
"no-octal": 2,
73-
"no-octal-escape": 2,
74-
"no-process-env": 2,
75-
"no-proto": 2,
76-
"no-redeclare": 2,
77-
"no-return-assign": 2,
78-
"no-script-url": 2,
79-
"no-self-compare": 2,
80-
"no-sequences": 2,
81-
"no-unused-expressions": 2,
82-
"no-void": 0,
83-
"no-warning-comments": 2,
84-
"no-with": 2,
85-
"prefer-arrow-callback": 2,
86-
"radix": 2,
87-
"vars-on-top": 0,
88-
"wrap-iife": 2,
89-
"yoda": 2,
90-
// Strict Mode
91-
"strict": [2, "global"],
92-
// Variables
93-
"prefer-const": 2,
94-
"no-catch-shadow": 2,
95-
"no-const-assign": 2,
96-
"no-delete-var": 2,
97-
"no-label-var": 2,
98-
"no-shadow": 2,
99-
"no-shadow-restricted-names": 2,
100-
"no-undef": 2,
101-
"no-undef-init": 2,
102-
"no-undefined": 2,
103-
"no-unused-vars": 2,
104-
"no-use-before-define": 2,
105-
"no-var": 2,
106-
// Stylistic Issues
107-
"indent": [2, 2, {
108-
"SwitchCase": 1
109-
}],
110-
"arrow-body-style": [2, "as-needed"],
111-
"arrow-parens": [2, "as-needed"],
112-
"arrow-spacing": 2,
113-
"brace-style": 2,
114-
"camelcase": 0,
115-
"comma-spacing": 2,
116-
"comma-style": 2,
117-
"consistent-this": 0,
118-
"eol-last": 2,
119-
"func-names": 0,
120-
"func-style": 0,
121-
"key-spacing": [2, {
122-
"beforeColon": false,
123-
"afterColon": true
124-
}],
125-
"max-nested-callbacks": 0,
126-
"new-cap": 2,
127-
"new-parens": 2,
128-
"no-array-constructor": 2,
129-
"no-inline-comments": 0,
130-
"no-lonely-if": 2,
131-
"no-mixed-spaces-and-tabs": 2,
132-
"no-nested-ternary": 2,
133-
"no-new-object": 2,
134-
"semi-spacing": [2, {
135-
"before": false,
136-
"after": true
137-
}],
138-
"no-spaced-func": 2,
139-
"no-ternary": 0,
140-
"no-trailing-spaces": 2,
141-
"no-multiple-empty-lines": 2,
142-
"no-underscore-dangle": 0,
143-
"one-var": 0,
144-
"operator-assignment": [2, "always"],
145-
"padded-blocks": [2, { "blocks": "never", "classes": "never", "switches": "never" }],
146-
"quotes": [2, "single"],
147-
"quote-props": [2, "as-needed"],
148-
"semi": [2, "always"],
149-
"sort-vars": [2, {"ignoreCase": true}],
150-
"keyword-spacing": 2,
151-
"space-before-blocks": 2,
15217
"object-curly-spacing": [2, "never"],
15318
"array-bracket-spacing": [2, "never"],
154-
"space-in-parens": 2,
155-
"space-infix-ops": 2,
156-
"space-unary-ops": 2,
157-
"spaced-comment": 2,
158-
"wrap-regex": 0,
159-
// Legacy
160-
"max-depth": 0,
16119
"max-len": [2, 120, {
16220
"ignoreStrings": true,
16321
"ignoreTemplateLiterals": true,
16422
"ignoreComments": true,
16523
}],
166-
"max-params": 0,
167-
"max-statements": 0,
168-
"no-plusplus": 0,
169-
"no-prototype-builtins": 2,
170-
"prefer-template": 2,
171-
"template-curly-spacing": [2, "never"]
172-
}
24+
"operator-linebreak": [2, "after"],
25+
"consistent-return": 0,
26+
27+
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
28+
29+
"function-paren-newline": 0,
30+
"no-plusplus": 1,
31+
"no-param-reassign": 1,
32+
"no-mixed-operators": 1,
33+
"global-require": 1,
34+
"no-restricted-syntax": 1,
35+
"valid-jsdoc": 1,
36+
},
37+
"overrides": [
38+
{
39+
"files": "tests/**",
40+
"rules": {
41+
"no-template-curly-in-string": 1,
42+
},
43+
},
44+
],
17345
}

index.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const has = require('has');
3+
const fromEntries = require('object.fromentries');
4+
const entries = require('object.entries');
45

56
const allRules = {
67
'boolean-prop-naming': require('./lib/rules/boolean-prop-naming'),
@@ -88,24 +89,11 @@ const allRules = {
8889
};
8990

9091
function filterRules(rules, predicate) {
91-
const result = {};
92-
for (const key in rules) {
93-
if (has(rules, key) && predicate(rules[key])) {
94-
result[key] = rules[key];
95-
}
96-
}
97-
return result;
92+
return fromEntries(entries(rules).filter(entry => predicate(entry[1])));
9893
}
9994

10095
function configureAsError(rules) {
101-
const result = {};
102-
for (const key in rules) {
103-
if (!has(rules, key)) {
104-
continue;
105-
}
106-
result[`react/${key}`] = 2;
107-
}
108-
return result;
96+
return fromEntries(Object.keys(rules).map(key => [`react/${key}`, 2]));
10997
}
11098

11199
const activeRules = filterRules(allRules, rule => !rule.meta.deprecated);
@@ -114,7 +102,7 @@ const activeRulesConfig = configureAsError(activeRules);
114102
const deprecatedRules = filterRules(allRules, rule => rule.meta.deprecated);
115103

116104
module.exports = {
117-
deprecatedRules: deprecatedRules,
105+
deprecatedRules,
118106
rules: allRules,
119107
configs: {
120108
recommended: {

0 commit comments

Comments
 (0)