Skip to content

Commit b0fccfb

Browse files
committed
update the eslint lib to v9
1 parent a68a160 commit b0fccfb

File tree

7 files changed

+569
-509
lines changed

7 files changed

+569
-509
lines changed

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {FlatCompat} from '@eslint/eslintrc'
2+
import js from '@eslint/js'
3+
import eslintPlugin from 'eslint-plugin-eslint-plugin'
4+
import globals from 'globals'
5+
import path from 'node:path'
6+
import {fileURLToPath} from 'node:url'
7+
8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = path.dirname(__filename)
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all,
14+
})
15+
16+
export default [
17+
...compat.extends('./lib/configs/recommended.js', 'plugin:eslint-plugin/all'),
18+
{
19+
plugins: {
20+
'eslint-plugin': eslintPlugin,
21+
},
22+
23+
languageOptions: {
24+
globals: {
25+
...globals.node,
26+
},
27+
28+
ecmaVersion: 2022,
29+
sourceType: 'module',
30+
},
31+
32+
rules: {
33+
'import/extensions': 'off',
34+
'import/no-commonjs': 'off',
35+
'filenames/match-regex': 'off',
36+
'i18n-text/no-en': 'off',
37+
'eslint-plugin/prefer-placeholders': 'off',
38+
'eslint-plugin/test-case-shorthand-strings': 'off',
39+
'eslint-plugin/require-meta-docs-url': 'off',
40+
'prettier/prettier': 'off',
41+
'no-unused-vars': 'off',
42+
},
43+
},
44+
]

lib/rules/async-currenttarget.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ module.exports = {
1212
const scopeDidWait = new WeakSet()
1313

1414
return {
15-
AwaitExpression() {
16-
scopeDidWait.add(context.getScope(), true)
15+
AwaitExpression(node) {
16+
const sourceCode = context.sourceCode
17+
const scope = sourceCode.getScope(node)
18+
scopeDidWait.add(scope, true)
1719
},
1820
MemberExpression(node) {
1921
if (node.property && node.property.name === 'currentTarget') {
20-
const scope = context.getScope()
22+
const sourceCode = context.sourceCode
23+
const scope = sourceCode.getScope(node)
2124
if (scope.block.async && scopeDidWait.has(scope)) {
2225
context.report({node, message: 'event.currentTarget inside an async function is error prone'})
2326
}

lib/rules/async-preventdefault.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ module.exports = {
1212
const scopeDidWait = new WeakSet()
1313

1414
return {
15-
AwaitExpression() {
16-
scopeDidWait.add(context.getScope(), true)
15+
AwaitExpression(node) {
16+
const sourceCode = context.sourceCode
17+
const scope = sourceCode.getScope(node)
18+
19+
scopeDidWait.add(scope, true)
1720
},
1821
CallExpression(node) {
1922
if (node.callee.property && node.callee.property.name === 'preventDefault') {
20-
const scope = context.getScope()
23+
const sourceCode = context.sourceCode
24+
const scope = sourceCode.getScope(node)
2125
if (scope.block.async && scopeDidWait.has(scope)) {
2226
context.report({node, message: 'event.preventDefault() inside an async function is error prone'})
2327
}

lib/rules/no-implicit-buggy-globals.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ module.exports = {
1010

1111
create(context) {
1212
return {
13-
Program() {
14-
const scope = context.getScope()
13+
Program(node) {
14+
const sourceCode = context.sourceCode
15+
const scope = sourceCode.getScope(node)
1516

1617
for (const variable of scope.variables) {
1718
if (variable.writeable) {

0 commit comments

Comments
 (0)