Skip to content

Commit 9a35641

Browse files
author
Yuqi Huang
committed
fix: update custom ESLint plugin for ESLint 10 compatibility
- Replace deprecated context.getSourceCode() with context.sourceCode - Restructure rule export to { meta, create } format required by flat config
1 parent 413ddd3 commit 9a35641

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

eslint/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ const sortedImports = require('./sorted-imports');
22

33
module.exports = {
44
rules: {
5-
'sorted-imports': {
6-
create: sortedImports,
7-
},
5+
'sorted-imports': sortedImports,
86
},
97
};

eslint/sorted-imports.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
function isBlankLineBefore(context, node) {
2-
return node.range[0] > 0 && !context.getSourceCode().getLocFromIndex(node.range[0] - 1).column;
2+
return node.range[0] > 0 && !context.sourceCode.getLocFromIndex(node.range[0] - 1).column;
33
}
44

55
function getText(context, node) {
6-
return context.getSourceCode().getText(node);
6+
return context.sourceCode.getText(node);
77
}
88

9-
module.exports = context => {
10-
let previousImport = null;
11-
let previousLocalImport = null;
9+
module.exports = {
10+
meta: {
11+
type: 'layout',
12+
fixable: 'whitespace',
13+
},
14+
create(context) {
15+
let previousImport = null;
16+
let previousLocalImport = null;
1217

13-
return {
14-
meta: {
15-
type: 'layout',
16-
fixable: 'whitespace',
17-
},
18-
ImportDeclaration(node) {
18+
return {
19+
ImportDeclaration(node) {
1920
const sourceValue = node.source.value;
2021

2122
if (sourceValue.startsWith('.') || sourceValue.startsWith('/')) {
@@ -120,4 +121,5 @@ module.exports = context => {
120121
}
121122
},
122123
};
124+
},
123125
};

0 commit comments

Comments
 (0)