5
5
"use strict"
6
6
7
7
const { Linter } = require ( "eslint" )
8
+ const semver = require ( "semver" )
8
9
9
- const isESLint7 = Linter . version . startsWith ( "7 ")
10
- const isESLint8 = Linter . version . startsWith ( "8 ")
10
+ const isESLint7OrHigher = semver . gte ( Linter . version , "7.0.0 ")
11
+ const isESLint8OrHigher = semver . gte ( Linter . version , "8.0.0 ")
11
12
12
13
/** @type {import('eslint').Linter.Config } */
13
14
module . exports = {
@@ -33,7 +34,7 @@ module.exports = {
33
34
"consistent-return" : "error" ,
34
35
curly : "error" ,
35
36
"default-case" : "error" ,
36
- ...( isESLint7 || isESLint8 ? { "default-case-last" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
37
+ ...( isESLint7OrHigher ? { "default-case-last" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
37
38
"default-param-last" : "error" ,
38
39
"dot-notation" : "error" ,
39
40
eqeqeq : [ "error" , "always" , { null : "ignore" } ] ,
@@ -44,7 +45,7 @@ module.exports = {
44
45
"init-declarations" : "error" ,
45
46
"linebreak-style" : [ "error" , "unix" ] ,
46
47
"lines-between-class-members" : "error" ,
47
- ...( isESLint8 ? { "logical-assignment-operators" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
48
+ ...( isESLint8OrHigher ? { "logical-assignment-operators" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
48
49
"max-statements-per-line" : [ "error" , { max : 1 } ] ,
49
50
"multiline-comment-style" : [ "error" , "separate-lines" ] ,
50
51
"new-cap" : "error" ,
@@ -55,7 +56,9 @@ module.exports = {
55
56
"no-case-declarations" : "error" ,
56
57
"no-compare-neg-zero" : "error" ,
57
58
"no-cond-assign" : "error" ,
58
- ...( isESLint8 ? { "no-constant-binary-expression" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
59
+ ...( isESLint8OrHigher
60
+ ? { "no-constant-binary-expression" : "off" }
61
+ : { } ) , // TODO: enable once we drop ESLint v7 support
59
62
"no-constant-condition" : "error" ,
60
63
"no-constructor-return" : "error" ,
61
64
"no-control-regex" : "error" ,
@@ -71,7 +74,7 @@ module.exports = {
71
74
"no-empty-character-class" : "error" ,
72
75
"no-empty-function" : "error" ,
73
76
"no-empty-pattern" : "error" ,
74
- ...( isESLint8 ? { "no-empty-static-block" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
77
+ ...( isESLint8OrHigher ? { "no-empty-static-block" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
75
78
"no-eval" : "error" ,
76
79
"no-ex-assign" : "error" ,
77
80
"no-extend-native" : "error" ,
@@ -102,7 +105,7 @@ module.exports = {
102
105
"no-lone-blocks" : "error" ,
103
106
"no-lonely-if" : "error" ,
104
107
"no-loop-func" : "error" ,
105
- ...( isESLint7 || isESLint8 ? { "no-loss-of-precision" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
108
+ ...( isESLint7OrHigher ? { "no-loss-of-precision" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
106
109
"no-misleading-character-class" : "error" ,
107
110
"no-mixed-operators" : [
108
111
"error" ,
@@ -114,22 +117,18 @@ module.exports = {
114
117
} ,
115
118
] ,
116
119
"no-new" : "error" ,
117
- ...( isESLint8 ? { "no-new-native-nonconstructor" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
120
+ ...( isESLint8OrHigher ? { "no-new-native-nonconstructor" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
118
121
"no-new-object" : "error" ,
119
122
"no-new-require" : "error" ,
120
123
"no-new-wrappers" : "error" ,
121
- ...( isESLint7 || isESLint8
122
- ? { "no-nonoctal-decimal-escape" : "off" }
123
- : { } ) , // TODO: enable once we drop ESLint v6 support
124
+ ...( isESLint7OrHigher ? { "no-nonoctal-decimal-escape" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
124
125
"no-obj-calls" : "error" ,
125
126
"no-octal" : "error" ,
126
127
"no-octal-escape" : "error" ,
127
128
"no-param-reassign" : [ "error" , { props : false } ] ,
128
129
"no-process-env" : "error" ,
129
130
"no-process-exit" : "error" ,
130
- ...( isESLint7 || isESLint8
131
- ? { "no-promise-executor-return" : "off" }
132
- : { } ) , // TODO: enable once we drop ESLint v6 support
131
+ ...( isESLint7OrHigher ? { "no-promise-executor-return" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
133
132
"no-prototype-builtins" : "error" ,
134
133
"no-redeclare" : [ "error" , { builtinGlobals : true } ] ,
135
134
"no-regex-spaces" : "error" ,
@@ -160,15 +159,15 @@ module.exports = {
160
159
"no-unmodified-loop-condition" : "error" ,
161
160
"no-unneeded-ternary" : "error" ,
162
161
"no-unreachable" : "error" ,
163
- ...( isESLint7 || isESLint8 ? { "no-unreachable-loop" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
162
+ ...( isESLint7OrHigher ? { "no-unreachable-loop" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
164
163
"no-unsafe-finally" : "error" ,
165
164
"no-unsafe-negation" : [ "error" , { enforceForOrderingRelations : true } ] ,
166
- ...( isESLint7 || isESLint8
167
- ? { "no-unsafe-optional-chaining" : "off" }
168
- : { } ) , // TODO: enable once we drop ESLint v6 support
165
+ ...( isESLint7OrHigher ? { "no-unsafe-optional-chaining" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
169
166
"no-unused-expressions" : "error" ,
170
167
"no-unused-labels" : "error" ,
171
- ...( isESLint8 ? { "no-unused-private-class-members" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
168
+ ...( isESLint8OrHigher
169
+ ? { "no-unused-private-class-members" : "off" }
170
+ : { } ) , // TODO: enable once we drop ESLint v7 support
172
171
"no-unused-vars" : [
173
172
"error" ,
174
173
{
@@ -180,9 +179,7 @@ module.exports = {
180
179
} ,
181
180
] ,
182
181
"no-use-before-define" : [ "error" , "nofunc" ] ,
183
- ...( isESLint7 || isESLint8
184
- ? { "no-useless-backreference" : "off" }
185
- : { } ) , // TODO: enable once we drop ESLint v6 support
182
+ ...( isESLint7OrHigher ? { "no-useless-backreference" : "off" } : { } ) , // TODO: enable once we drop ESLint v6 support
186
183
"no-useless-call" : "error" ,
187
184
"no-useless-catch" : "error" ,
188
185
"no-useless-concat" : "error" ,
@@ -204,7 +201,7 @@ module.exports = {
204
201
{ blankLine : "always" , next : "*" , prev : "function" } ,
205
202
] ,
206
203
"prefer-exponentiation-operator" : "error" ,
207
- ...( isESLint8 ? { "prefer-object-has-own" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
204
+ ...( isESLint8OrHigher ? { "prefer-object-has-own" : "off" } : { } ) , // TODO: enable once we drop ESLint v7 support
208
205
"prefer-promise-reject-errors" : "error" ,
209
206
"prefer-regex-literals" : "error" ,
210
207
quotes : [ "error" , "double" , { avoidEscape : true } ] ,
0 commit comments