forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: drop eslint v7 & node.js < 18 (#161)
chore: switch to new rule-tester. Signed-off-by: 唯然 <[email protected]> Co-authored-by: Sebastian Good <[email protected]>
- Loading branch information
1 parent
c191101
commit 41ceed7
Showing
45 changed files
with
542 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
registry=https://registry.npmjs.org/ | ||
registry = https://registry.npmjs.org/ | ||
package-lock = false | ||
force = true | ||
legacy-peer-deps = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @fileoverview Helpers for tests. | ||
* @author 唯然<[email protected]> | ||
*/ | ||
"use strict" | ||
const eslintVersion = require("eslint/package.json").version | ||
const { RuleTester } = require("eslint") | ||
const { FlatRuleTester } = require("eslint/use-at-your-own-risk") | ||
const globals = require("globals") | ||
const semverSatisfies = require("semver/functions/satisfies") | ||
|
||
// greater than or equal to ESLint v9 | ||
exports.gteEslintV9 = semverSatisfies(eslintVersion, ">=9", { | ||
includePrerelease: true, | ||
}) | ||
|
||
exports.FlatRuleTester = exports.gteEslintV9 ? RuleTester : FlatRuleTester | ||
|
||
// to support the `env:{ es6: true, node: true}` rule-tester (env has been away in flat config.) | ||
// * enabled by default as it's most commonly used in the package. | ||
// * to disable the node.js globals: {languageOptions: {env: {node: false}}}. | ||
const defaultConfig = { | ||
languageOptions: { | ||
ecmaVersion: 6, | ||
sourceType: "commonjs", | ||
globals: globals.node, | ||
}, | ||
} | ||
exports.RuleTester = function (config = defaultConfig) { | ||
if (config.languageOptions.env?.node === false) | ||
config.languageOptions.globals = config.languageOptions.globals || {} | ||
delete config.languageOptions.env | ||
|
||
config.languageOptions = Object.assign( | ||
{}, | ||
defaultConfig.languageOptions, | ||
config.languageOptions | ||
) | ||
|
||
const ruleTester = new exports.FlatRuleTester(config) | ||
return ruleTester | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.