Skip to content

Commit 15458bf

Browse files
feat: add new eslint rules and configure for use with eslint-functional 5
1 parent 90a37ef commit 15458bf

File tree

9 files changed

+126
-154
lines changed

9 files changed

+126
-154
lines changed

src/builtin/es6.ts

-53
This file was deleted.

src/builtin/index.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import type { Linter } from "eslint";
22

3-
import { rules as bestPractices } from "./best-practices";
43
import { rules as deprecated } from "./deprecated";
5-
import { rules as es6 } from "./es6";
6-
import { rules as possibleErrors } from "./possible-errors";
7-
import { rules as strict } from "./strict";
8-
import { rules as stylisticIssues } from "./stylistic-issues";
9-
import { rules as variables } from "./variables";
4+
import { rules as layout } from "./layout+formatting";
5+
import { rules as possibleProblems } from "./possible-problems";
6+
import { rules as suggestions } from "./suggestions";
107

118
export const rules: Linter.Config["rules"] = {
12-
...bestPractices,
13-
...es6,
14-
...possibleErrors,
15-
...strict,
16-
...stylisticIssues,
17-
...variables,
9+
...possibleProblems,
10+
...suggestions,
11+
...layout,
1812
...deprecated,
1913
};

src/builtin/stylistic-issues.ts renamed to src/builtin/layout+formatting.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Linter } from "eslint";
22

33
export const rules: Linter.Config["rules"] = {
44
"array-bracket-spacing": ["error", "never"],
5+
"arrow-parens": ["error", "always"],
6+
"arrow-spacing": ["error", { before: true, after: true }],
57
"block-spacing": ["error", "always"],
68
"brace-style": "error",
79
"capitalized-comments": "off",
@@ -19,12 +21,14 @@ export const rules: Linter.Config["rules"] = {
1921
"comma-style": ["error", "last"],
2022
"computed-property-spacing": "error",
2123
"consistent-this": "off",
24+
"dot-location": ["error", "property"],
2225
"eol-last": "error",
2326
"func-call-spacing": ["error", "never"],
2427
"func-name-matching": "error",
2528
"func-names": ["error", "as-needed"],
2629
"func-style": ["error", "declaration", { allowArrowFunctions: true }],
2730
"function-paren-newline": "off",
31+
"generator-star-spacing": ["error", "after"],
2832
"implicit-arrow-linebreak": "off",
2933
"indent": [
3034
"error",
@@ -160,6 +164,12 @@ export const rules: Linter.Config["rules"] = {
160164
"no-underscore-dangle": "off",
161165
"no-unneeded-ternary": "error",
162166
"no-whitespace-before-property": "error",
167+
"no-multi-spaces": [
168+
"error",
169+
{
170+
ignoreEOLComments: true,
171+
},
172+
],
163173
"nonblock-statement-body-position": [
164174
"error",
165175
"beside",
@@ -230,6 +240,7 @@ export const rules: Linter.Config["rules"] = {
230240
allowTemplateLiterals: true,
231241
},
232242
],
243+
"rest-spread-spacing": ["error", "never"],
233244
"semi": ["error", "always"],
234245
"semi-spacing": ["error", { before: false, after: true }],
235246
"semi-style": ["error", "last"],
@@ -267,7 +278,15 @@ export const rules: Linter.Config["rules"] = {
267278
},
268279
],
269280
"switch-colon-spacing": ["error", { after: true, before: false }],
281+
"template-curly-spacing": ["error", "never"],
270282
"template-tag-spacing": ["error", "never"],
271283
"unicode-bom": ["error", "never"],
272-
"wrap-regex": "off",
284+
"wrap-iife": [
285+
"error",
286+
"inside",
287+
{
288+
functionPrototypeMethods: true,
289+
},
290+
],
291+
"yield-star-spacing": ["error", "after"],
273292
};

src/builtin/possible-errors.ts renamed to src/builtin/possible-problems.ts

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import type { Linter } from "eslint";
22

33
export const rules: Linter.Config["rules"] = {
4+
"constructor-super": "error",
45
"for-direction": "error",
56
"getter-return": "error",
67
"no-await-in-loop": "error",
78
"no-compare-neg-zero": "error",
89
"no-cond-assign": ["error", "always"],
910
"no-console": "off",
11+
"no-constant-binary-expression": "error",
1012
"no-constant-condition": "error",
13+
"no-constructor-return": "error",
1114
"no-control-regex": "error",
1215
"no-debugger": "warn",
1316
"no-dupe-args": "error",
1417
"no-dupe-keys": "error",
1518
"no-duplicate-case": "error",
16-
"no-empty": ["warn", { allowEmptyCatch: true }],
1719
"no-empty-character-class": "error",
20+
"no-empty-pattern": "error",
21+
"no-empty": ["warn", { allowEmptyCatch: true }],
1822
"no-ex-assign": "error",
1923
"no-extra-boolean-cast": "error",
2024
"no-extra-parens": [
@@ -24,21 +28,51 @@ export const rules: Linter.Config["rules"] = {
2428
nestedBinaryExpressions: false,
2529
},
2630
],
31+
"no-class-assign": "error",
32+
"no-const-assign": "error",
33+
"no-dupe-class-members": "error",
34+
"no-duplicate-imports": "off",
2735
"no-extra-semi": "error",
36+
"no-fallthrough": "error",
2837
"no-func-assign": "error",
2938
"no-inner-declarations": ["error", "functions"],
3039
"no-invalid-regexp": "error",
3140
"no-irregular-whitespace": "error",
3241
"no-misleading-character-class": "error",
42+
"no-new-symbol": "error",
3343
"no-obj-calls": "error",
44+
"no-promise-executor-return": "error",
3445
"no-prototype-builtins": "error",
3546
"no-regex-spaces": "error",
47+
"no-self-assign": "error",
48+
"no-self-compare": "error",
3649
"no-sparse-arrays": "error",
3750
"no-template-curly-in-string": "warn",
51+
"no-this-before-super": "error",
52+
"no-undef": "error",
3853
"no-unexpected-multiline": "error",
54+
"no-unmodified-loop-condition": "error",
55+
"no-unreachable-loop": "error",
3956
"no-unreachable": "error",
4057
"no-unsafe-finally": "error",
4158
"no-unsafe-negation": "error",
59+
"no-unused-private-class-members": "error",
60+
"no-unused-vars": [
61+
"error",
62+
{
63+
vars: "all",
64+
args: "after-used",
65+
ignoreRestSiblings: true,
66+
},
67+
],
68+
"no-use-before-define": [
69+
"error",
70+
{
71+
functions: true,
72+
classes: true,
73+
variables: true,
74+
},
75+
],
4276
"require-atomic-updates": "error",
4377
"use-isnan": "error",
4478
"valid-typeof": [

src/builtin/strict.ts

-5
This file was deleted.

src/builtin/best-practices.ts renamed to src/builtin/suggestions.ts

+64-31
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ const useObjectDefineProperty = "Please use Object.defineProperty instead.";
66

77
export const rules: Linter.Config["rules"] = {
88
"accessor-pairs": "error",
9+
"arrow-body-style": ["error", "as-needed"],
910
"block-scoped-var": "error",
1011
"class-methods-use-this": "error",
11-
"complexity": "off",
1212
"consistent-return": [
1313
"error",
1414
{
1515
treatUndefinedAsUnspecified: false,
1616
},
1717
],
1818
"curly": ["error", "all"],
19-
"default-case": "off",
20-
"dot-location": ["error", "property"],
19+
"default-case-last": "error",
20+
"default-param-last": "error",
2121
"dot-notation": "error",
2222
"eqeqeq": ["error", "always", { null: "always" }],
23+
"grouped-accessor-pairs": "error",
2324
"guard-for-in": "error",
25+
"init-declarations": "off",
26+
"logical-assignment-operators": "error",
2427
"max-classes-per-file": ["error", 1],
2528
"no-alert": "error",
2629
"no-caller": "error",
2730
"no-case-declarations": "error",
28-
"no-div-regex": "off",
2931
"no-else-return": [
3032
"error",
3133
{
3234
allowElseIf: false,
3335
},
3436
],
35-
"no-empty-function": ["error"],
36-
"no-empty-pattern": "error",
37+
"no-empty-function": "error",
3738
"no-eq-null": "error",
3839
"no-eval": "error",
3940
"no-extend-native": "error",
4041
"no-extra-bind": "error",
4142
"no-extra-label": "error",
42-
"no-fallthrough": "error",
4343
"no-floating-decimal": "error",
4444
"no-global-assign": "error",
4545
"no-implicit-coercion": "error",
@@ -50,19 +50,13 @@ export const rules: Linter.Config["rules"] = {
5050
"no-labels": "error",
5151
"no-lone-blocks": "error",
5252
"no-loop-func": "error",
53-
"no-magic-numbers": "off",
54-
"no-multi-spaces": [
55-
"error",
56-
{
57-
ignoreEOLComments: true,
58-
},
59-
],
6053
"no-multi-str": "off",
61-
"no-new": "error",
6254
"no-new-func": "error",
55+
"no-new-object": "error",
6356
"no-new-wrappers": "error",
64-
"no-octal": "error",
57+
"no-new": "error",
6558
"no-octal-escape": "error",
59+
"no-octal": "error",
6660
"no-param-reassign": "error",
6761
"no-proto": "error",
6862
"no-redeclare": "error",
@@ -111,41 +105,80 @@ export const rules: Linter.Config["rules"] = {
111105
property: "__defineSetter__",
112106
message: useObjectDefineProperty,
113107
},
108+
],
109+
"object-shorthand": "error",
110+
"no-delete-var": "error",
111+
"no-label-var": "error",
112+
"no-restricted-globals": [
113+
"error",
114114
{
115-
object: "Math",
116-
property: "pow",
117-
message: "Use the exponentiation operator (**) instead.",
115+
name: "event",
116+
message: "Use local parameter instead.",
118117
},
119118
],
120119
"no-return-assign": "error",
121120
"no-return-await": "error",
122121
"no-script-url": "error",
123-
"no-self-assign": "error",
124-
"no-self-compare": "error",
125122
"no-sequences": "error",
123+
"no-shadow": [
124+
"warn",
125+
{
126+
builtinGlobals: false,
127+
hoist: "never",
128+
allow: ["resolve", "reject", "done", "cb"],
129+
},
130+
],
131+
"no-shadow-restricted-names": "error",
126132
"no-throw-literal": "error",
127-
"no-unmodified-loop-condition": "error",
128133
"no-unused-expressions": "error",
129134
"no-unused-labels": "error",
130135
"no-useless-call": "error",
136+
"no-useless-computed-key": "error",
131137
"no-useless-concat": "error",
138+
"no-useless-constructor": "warn",
132139
"no-useless-escape": "error",
140+
"no-useless-rename": "error",
133141
"no-useless-return": "error",
142+
"no-var": "error",
134143
"no-void": "off",
135144
"no-warning-comments": "off",
136145
"no-with": "error",
137-
"prefer-named-capture-group": "off",
138-
"prefer-promise-reject-errors": "error",
139-
"radix": "error",
140-
"require-await": "off",
141-
"require-unicode-regexp": "error",
142-
"vars-on-top": "off",
143-
"wrap-iife": [
146+
"prefer-arrow-callback": "error",
147+
"prefer-const": [
148+
"error",
149+
{
150+
destructuring: "all",
151+
},
152+
],
153+
"prefer-destructuring": [
144154
"error",
145-
"inside",
146155
{
147-
functionPrototypeMethods: true,
156+
VariableDeclarator: {
157+
array: false,
158+
object: true,
159+
},
160+
AssignmentExpression: {
161+
array: true,
162+
object: true,
163+
},
164+
},
165+
{
166+
enforceForRenamedProperties: false,
148167
},
149168
],
169+
"prefer-exponentiation-operator": "error",
170+
"prefer-numeric-literals": "error",
171+
"prefer-object-has-own": "error",
172+
"prefer-promise-reject-errors": "error",
173+
"prefer-regex-literals": "error",
174+
"prefer-rest-params": "error",
175+
"prefer-spread": "error",
176+
"prefer-template": "error",
177+
"radix": "error",
178+
"require-await": "error",
179+
"require-unicode-regexp": "error",
180+
"require-yield": "error",
181+
"strict": ["error", "never"],
182+
"symbol-description": "error",
150183
"yoda": ["error", "never"],
151184
};

0 commit comments

Comments
 (0)