Skip to content

Commit 6a03dcf

Browse files
chore: use semver in _base config as well (#54)
1 parent 77e43ed commit 6a03dcf

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

lib/configs/_base.js

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"use strict"
66

77
const { Linter } = require("eslint")
8+
const semver = require("semver")
89

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")
1112

1213
/** @type {import('eslint').Linter.Config} */
1314
module.exports = {
@@ -33,7 +34,7 @@ module.exports = {
3334
"consistent-return": "error",
3435
curly: "error",
3536
"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
3738
"default-param-last": "error",
3839
"dot-notation": "error",
3940
eqeqeq: ["error", "always", { null: "ignore" }],
@@ -44,7 +45,7 @@ module.exports = {
4445
"init-declarations": "error",
4546
"linebreak-style": ["error", "unix"],
4647
"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
4849
"max-statements-per-line": ["error", { max: 1 }],
4950
"multiline-comment-style": ["error", "separate-lines"],
5051
"new-cap": "error",
@@ -55,7 +56,9 @@ module.exports = {
5556
"no-case-declarations": "error",
5657
"no-compare-neg-zero": "error",
5758
"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
5962
"no-constant-condition": "error",
6063
"no-constructor-return": "error",
6164
"no-control-regex": "error",
@@ -71,7 +74,7 @@ module.exports = {
7174
"no-empty-character-class": "error",
7275
"no-empty-function": "error",
7376
"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
7578
"no-eval": "error",
7679
"no-ex-assign": "error",
7780
"no-extend-native": "error",
@@ -102,7 +105,7 @@ module.exports = {
102105
"no-lone-blocks": "error",
103106
"no-lonely-if": "error",
104107
"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
106109
"no-misleading-character-class": "error",
107110
"no-mixed-operators": [
108111
"error",
@@ -114,22 +117,18 @@ module.exports = {
114117
},
115118
],
116119
"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
118121
"no-new-object": "error",
119122
"no-new-require": "error",
120123
"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
124125
"no-obj-calls": "error",
125126
"no-octal": "error",
126127
"no-octal-escape": "error",
127128
"no-param-reassign": ["error", { props: false }],
128129
"no-process-env": "error",
129130
"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
133132
"no-prototype-builtins": "error",
134133
"no-redeclare": ["error", { builtinGlobals: true }],
135134
"no-regex-spaces": "error",
@@ -160,15 +159,15 @@ module.exports = {
160159
"no-unmodified-loop-condition": "error",
161160
"no-unneeded-ternary": "error",
162161
"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
164163
"no-unsafe-finally": "error",
165164
"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
169166
"no-unused-expressions": "error",
170167
"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
172171
"no-unused-vars": [
173172
"error",
174173
{
@@ -180,9 +179,7 @@ module.exports = {
180179
},
181180
],
182181
"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
186183
"no-useless-call": "error",
187184
"no-useless-catch": "error",
188185
"no-useless-concat": "error",
@@ -204,7 +201,7 @@ module.exports = {
204201
{ blankLine: "always", next: "*", prev: "function" },
205202
],
206203
"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
208205
"prefer-promise-reject-errors": "error",
209206
"prefer-regex-literals": "error",
210207
quotes: ["error", "double", { avoidEscape: true }],

0 commit comments

Comments
 (0)