Skip to content

Commit

Permalink
chore: use semver in _base config as well (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Jan 5, 2023
1 parent 77e43ed commit 6a03dcf
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions lib/configs/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"use strict"

const { Linter } = require("eslint")
const semver = require("semver")

const isESLint7 = Linter.version.startsWith("7")
const isESLint8 = Linter.version.startsWith("8")
const isESLint7OrHigher = semver.gte(Linter.version, "7.0.0")
const isESLint8OrHigher = semver.gte(Linter.version, "8.0.0")

/** @type {import('eslint').Linter.Config} */
module.exports = {
Expand All @@ -33,7 +34,7 @@ module.exports = {
"consistent-return": "error",
curly: "error",
"default-case": "error",
...(isESLint7 || isESLint8 ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"default-param-last": "error",
"dot-notation": "error",
eqeqeq: ["error", "always", { null: "ignore" }],
Expand All @@ -44,7 +45,7 @@ module.exports = {
"init-declarations": "error",
"linebreak-style": ["error", "unix"],
"lines-between-class-members": "error",
...(isESLint8 ? { "logical-assignment-operators": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher ? { "logical-assignment-operators": "off" } : {}), // TODO: enable once we drop ESLint v7 support
"max-statements-per-line": ["error", { max: 1 }],
"multiline-comment-style": ["error", "separate-lines"],
"new-cap": "error",
Expand All @@ -55,7 +56,9 @@ module.exports = {
"no-case-declarations": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
...(isESLint8 ? { "no-constant-binary-expression": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher
? { "no-constant-binary-expression": "off" }
: {}), // TODO: enable once we drop ESLint v7 support
"no-constant-condition": "error",
"no-constructor-return": "error",
"no-control-regex": "error",
Expand All @@ -71,7 +74,7 @@ module.exports = {
"no-empty-character-class": "error",
"no-empty-function": "error",
"no-empty-pattern": "error",
...(isESLint8 ? { "no-empty-static-block": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher ? { "no-empty-static-block": "off" } : {}), // TODO: enable once we drop ESLint v7 support
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "error",
Expand Down Expand Up @@ -102,7 +105,7 @@ module.exports = {
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
...(isESLint7 || isESLint8 ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-misleading-character-class": "error",
"no-mixed-operators": [
"error",
Expand All @@ -114,22 +117,18 @@ module.exports = {
},
],
"no-new": "error",
...(isESLint8 ? { "no-new-native-nonconstructor": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher ? { "no-new-native-nonconstructor": "off" } : {}), // TODO: enable once we drop ESLint v7 support
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
...(isESLint7 || isESLint8
? { "no-nonoctal-decimal-escape": "off" }
: {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-nonoctal-decimal-escape": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": ["error", { props: false }],
"no-process-env": "error",
"no-process-exit": "error",
...(isESLint7 || isESLint8
? { "no-promise-executor-return": "off" }
: {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-promise-executor-return": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-prototype-builtins": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"no-regex-spaces": "error",
Expand Down Expand Up @@ -160,15 +159,15 @@ module.exports = {
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
...(isESLint7 || isESLint8 ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-unsafe-finally": "error",
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
...(isESLint7 || isESLint8
? { "no-unsafe-optional-chaining": "off" }
: {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-unsafe-optional-chaining": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-unused-expressions": "error",
"no-unused-labels": "error",
...(isESLint8 ? { "no-unused-private-class-members": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher
? { "no-unused-private-class-members": "off" }
: {}), // TODO: enable once we drop ESLint v7 support
"no-unused-vars": [
"error",
{
Expand All @@ -180,9 +179,7 @@ module.exports = {
},
],
"no-use-before-define": ["error", "nofunc"],
...(isESLint7 || isESLint8
? { "no-useless-backreference": "off" }
: {}), // TODO: enable once we drop ESLint v6 support
...(isESLint7OrHigher ? { "no-useless-backreference": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-concat": "error",
Expand All @@ -204,7 +201,7 @@ module.exports = {
{ blankLine: "always", next: "*", prev: "function" },
],
"prefer-exponentiation-operator": "error",
...(isESLint8 ? { "prefer-object-has-own": "off" } : {}), // TODO: enable once we drop ESLint v7 support
...(isESLint8OrHigher ? { "prefer-object-has-own": "off" } : {}), // TODO: enable once we drop ESLint v7 support
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": "error",
quotes: ["error", "double", { avoidEscape: true }],
Expand Down

0 comments on commit 6a03dcf

Please sign in to comment.