Skip to content

Commit aebd4f2

Browse files
committed
fix: add ESLint 10 compatibility by replacing deprecated context.getSourceCode()
1 parent a15aa2a commit aebd4f2

39 files changed

Lines changed: 79 additions & 51 deletions

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,25 @@ jobs:
4646

4747
- run: pnpm install
4848
- run: pnpm test:coverage
49+
50+
eslint-versions:
51+
runs-on: ubuntu-latest
52+
strategy:
53+
matrix:
54+
eslint-version: [8, 9, 10]
55+
56+
steps:
57+
- uses: actions/checkout@v6
58+
- uses: pnpm/action-setup@v4
59+
with:
60+
run_install: false
61+
- uses: actions/setup-node@v6
62+
with:
63+
node-version: 22.x
64+
cache: 'pnpm'
65+
66+
- run: pnpm install
67+
- name: Install ESLint ${{ matrix.eslint-version }}
68+
run: pnpm add -D eslint@${{ matrix.eslint-version }} --ignore-workspace-root-check
69+
- name: Test with ESLint ${{ matrix.eslint-version }}
70+
run: pnpm test

lib/rules/alias-model-in-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
context.report({ node, message });
2929
};
3030

31-
const sourceCode = context.getSourceCode();
31+
const sourceCode = context.sourceCode ?? context.getSourceCode();
3232
const { scopeManager } = sourceCode;
3333

3434
return {

lib/rules/avoid-leaking-state-in-ember-objects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
context.report({ node, message });
8181
};
8282

83-
const sourceCode = context.getSourceCode();
83+
const sourceCode = context.sourceCode ?? context.getSourceCode();
8484
const { scopeManager } = sourceCode;
8585

8686
return {

lib/rules/avoid-using-needs-in-controllers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
context.report({ node, message });
2828
};
2929

30-
const sourceCode = context.getSourceCode();
30+
const sourceCode = context.sourceCode ?? context.getSourceCode();
3131
const { scopeManager } = sourceCode;
3232

3333
return {

lib/rules/no-actions-hash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
},
2020

2121
create: (context) => {
22-
const sourceCode = context.getSourceCode();
22+
const sourceCode = context.sourceCode ?? context.getSourceCode();
2323
const { scopeManager } = sourceCode;
2424

2525
function reportActionsProp(properties) {

lib/rules/no-array-prototype-extensions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function applyFix(callExpressionNode, fixer, context, options = {}) {
180180
const propertyName = calleeProp.name;
181181
const calleeObj = callExpressionNode.callee.object;
182182
const callArgs = callExpressionNode.arguments;
183-
const sourceCode = context.getSourceCode();
183+
const sourceCode = context.sourceCode ?? context.getSourceCode();
184184

185185
// Get the open parenthesis immediately after the callee name
186186
const openParenToken = sourceCode.getTokenAfter(calleeProp, {
@@ -644,7 +644,7 @@ module.exports = {
644644
},
645645

646646
create(context) {
647-
const sourceCode = context.getSourceCode();
647+
const sourceCode = context.sourceCode ?? context.getSourceCode();
648648
const { scopeManager } = sourceCode;
649649
let importedGetName;
650650
let importedSetName;

lib/rules/no-assignment-of-untracked-properties-used-in-tracking-contexts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ module.exports = {
310310

311311
const currentClass = classStack.peek();
312312

313-
const sourceCode = context.getSourceCode();
313+
const sourceCode = context.sourceCode ?? context.getSourceCode();
314314
const nodeTextLeft = sourceCode.getText(node.left);
315315
const nodeTextRight = sourceCode.getText(node.right);
316316
const propertyName = nodeTextLeft.replace('this.', '');
@@ -348,7 +348,7 @@ module.exports = {
348348
);
349349
} else {
350350
// Need to add an import statement for `set`.
351-
const sourceCode = context.getSourceCode();
351+
const sourceCode = context.sourceCode ?? context.getSourceCode();
352352
return [
353353
fixer.insertTextBefore(sourceCode.ast, "import { set } from '@ember/object';\n"),
354354
fixer.replaceText(node, `set(this, '${propertyName}', ${nodeTextRight})`),

lib/rules/no-classic-classes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = {
6969
},
7070

7171
create(context) {
72-
const sourceCode = context.getSourceCode();
72+
const sourceCode = context.sourceCode ?? context.getSourceCode();
7373
const { scopeManager } = sourceCode;
7474
const options = context.options[0] || {};
7575
const additionalClassImports = options.additionalClassImports || [];

lib/rules/no-controllers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
},
2222

2323
create: (context) => {
24-
const sourceCode = context.getSourceCode();
24+
const sourceCode = context.sourceCode ?? context.getSourceCode();
2525
const { scopeManager } = sourceCode;
2626

2727
return {

lib/rules/no-deprecated-router-transition-methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const decoratorUtils = require('../utils/decorators');
88

99
function getBaseFixSteps(fixer, context, currentClass) {
1010
const fixSteps = [];
11-
const sourceCode = context.getSourceCode();
11+
const sourceCode = context.sourceCode ?? context.getSourceCode();
1212
let serviceInjectImportName = currentClass.serviceInjectImportName;
1313
let routerServicePropertyName = currentClass.routerServicePropertyName;
1414

0 commit comments

Comments
 (0)