-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support eslint.config.js #95
Changes from all commits
9c0e322
cc19d35
97d3d09
dea40ad
a3a0dfb
58cbfcb
ccfbeb3
52125ff
4eea92b
e5585fa
4979148
5fc4dac
dcf6f66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @fileoverview the `recommended-module` config for `eslint.config.js` | ||
* @author 唯然<[email protected]> | ||
*/ | ||
|
||
"use strict" | ||
|
||
const mod = require("../lib/index.js") | ||
|
||
module.exports = { | ||
plugins: { n: mod }, | ||
languageOptions: { | ||
sourceType: "module", | ||
globals: mod.configs["recommended-module"].globals, | ||
}, | ||
rules: mod.configs["recommended-module"].rules, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @fileoverview the `recommended-script` config for `eslint.config.js` | ||
* @author 唯然<[email protected]> | ||
*/ | ||
|
||
"use strict" | ||
|
||
const mod = require("../lib/index.js") | ||
|
||
module.exports = { | ||
plugins: { n: mod }, | ||
languageOptions: { | ||
sourceType: "commonjs", | ||
globals: mod.configs["recommended-script"].globals, | ||
}, | ||
rules: mod.configs["recommended-script"].rules, | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||
/** | ||||||||
* @author 唯然<[email protected]> | ||||||||
*/ | ||||||||
"use strict" | ||||||||
|
||||||||
const js = require("@eslint/js") | ||||||||
const { FlatCompat } = require("@eslint/eslintrc") | ||||||||
const globals = require("globals") | ||||||||
const nodeRecommended = require("eslint-plugin-n/configs/recommended-script") | ||||||||
|
||||||||
const compat = new FlatCompat({ | ||||||||
baseDirectory: __dirname, | ||||||||
recommendedConfig: js.configs.recommended, | ||||||||
}) | ||||||||
|
||||||||
module.exports = [ | ||||||||
mdjermanovic marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
{ | ||||||||
languageOptions: { globals: globals.mocha }, | ||||||||
linterOptions: { reportUnusedDisableDirectives: true }, | ||||||||
}, | ||||||||
{ | ||||||||
ignores: [ | ||||||||
".nyc_output/", | ||||||||
"coverage/", | ||||||||
"docs/", | ||||||||
"lib/converted-esm/", | ||||||||
"test/fixtures/", | ||||||||
], | ||||||||
}, | ||||||||
js.configs.recommended, | ||||||||
nodeRecommended, | ||||||||
...compat.extends("plugin:eslint-plugin/recommended", "prettier"), | ||||||||
{ rules: { "eslint-plugin/require-meta-docs-description": "error" } }, | ||||||||
{ | ||||||||
// these messageIds were used outside | ||||||||
files: ["lib/rules/prefer-global/*.js"], | ||||||||
rules: { | ||||||||
"eslint-plugin/no-unused-message-ids": 0, | ||||||||
}, | ||||||||
}, | ||||||||
] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compared to the previous (.eslintrc.js) config, this one might be missing this rule: Lines 20 to 22 in bea9981
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,25 @@ | |
}, | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
"lib/", | ||
"configs/" | ||
], | ||
"peerDependencies": { | ||
"eslint": ">=7.0.0" | ||
}, | ||
"dependencies": { | ||
"@eslint-community/eslint-utils": "^4.4.0", | ||
"builtins": "^5.0.1", | ||
"eslint-plugin-es-x": "^6.1.0", | ||
"@eslint-community/eslint-utils": "^4.4.0", | ||
"ignore": "^5.1.1", | ||
"is-core-module": "^2.12.0", | ||
"minimatch": "^3.1.2", | ||
"resolve": "^1.22.2", | ||
"semver": "^7.5.0" | ||
}, | ||
"devDependencies": { | ||
"@eslint/eslintrc": "^2.0.2", | ||
"@eslint/js": "^8.38.0", | ||
"@typescript-eslint/parser": "^5.59.0", | ||
"codecov": "^3.3.0", | ||
"esbuild": "^0.17.17", | ||
|
@@ -56,7 +59,7 @@ | |
"lint": "npm-run-all \"lint:*\"", | ||
"lint:docs": "markdownlint \"**/*.md\"", | ||
"lint:eslint-docs": "npm run update:eslint-docs -- --check", | ||
"lint:js": "eslint lib scripts tests/lib .eslintrc.js", | ||
"lint:js": "eslint .", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compared to the previous version, this will now lint |
||
"new": "node scripts/new-rule", | ||
"postversion": "git push && git push --tags", | ||
"prepare": "npx husky install", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there should also be an example with
configs/recommended-module
, for ESM ("type": "module"
) projects?