Skip to content

Commit f82a064

Browse files
committed
Replace deprecated ESLint context methods in newly added rules
Apply the same ESLint 10 compatibility fixes to rules added since the original commit: context.getSourceCode() → context.sourceCode, context.getFilename() → context.filename, and remove fallback patterns.
1 parent ee52f1f commit f82a064

19 files changed

Lines changed: 22 additions & 22 deletions

lib/rules/no-tracked-built-ins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module.exports = {
123123
messageId: 'newExpression',
124124
data: { oldName, newName },
125125
fix(fixer) {
126-
const sourceCode = context.getSourceCode();
126+
const sourceCode = context.sourceCode;
127127
const newKeyword = sourceCode.getFirstToken(node);
128128
const calleeToken = sourceCode.getTokenAfter(newKeyword);
129129
const fixes = [

lib/rules/template-attribute-order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
},
3131

3232
create(context) {
33-
const sourceCode = context.sourceCode || context.getSourceCode();
33+
const sourceCode = context.sourceCode;
3434

3535
const options = context.options[0] || {};
3636
const order = options.order || [

lib/rules/template-block-indentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ module.exports = {
168168
let config;
169169
if (options === undefined) {
170170
// No explicit config — try .editorconfig for indent_size
171-
const filePath = context.filename || context.getFilename();
171+
const filePath = context.filename;
172172
const editorConfig = editorConfigUtil.resolveEditorConfig(filePath);
173173
const indent = editorConfig.indent_size;
174174
config = { indentation: typeof indent === 'number' ? indent : 2 };

lib/rules/template-builtin-component-arguments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
},
2525

2626
create(context) {
27-
const filename = context.filename ?? context.getFilename();
27+
const filename = context.filename;
2828
const isStrictMode = filename.endsWith('.gjs') || filename.endsWith('.gts');
2929

3030
// In GJS/GTS, track imports from @ember/component to distinguish

lib/rules/template-eol-last.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
let config = option;
3636

3737
if (option === 'editorconfig') {
38-
const editorConfig = editorConfigUtil.resolveEditorConfig(context.getFilename());
38+
const editorConfig = editorConfigUtil.resolveEditorConfig(context.filename);
3939
const insertFinalNewline = editorConfig['insert_final_newline'];
4040
if (typeof insertFinalNewline === 'boolean') {
4141
config = insertFinalNewline ? 'always' : 'never';
@@ -46,7 +46,7 @@ module.exports = {
4646
}
4747
}
4848

49-
const sourceCode = context.getSourceCode();
49+
const sourceCode = context.sourceCode;
5050

5151
return {
5252
'GlimmerTemplate:exit'(node) {

lib/rules/template-linebreak-style.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
const option = context.options[0] || 'unix';
4141

4242
// editorconfig end_of_line takes precedence over the rule option
43-
const editorConfig = editorConfigUtil.resolveEditorConfig(context.getFilename());
43+
const editorConfig = editorConfigUtil.resolveEditorConfig(context.filename);
4444
const editorConfigEol = editorConfig['end_of_line'];
4545

4646
let expectedLinebreak;
@@ -54,7 +54,7 @@ module.exports = {
5454
expectedLinebreak = '\n';
5555
}
5656

57-
const sourceCode = context.getSourceCode();
57+
const sourceCode = context.sourceCode;
5858

5959
return {
6060
'GlimmerTemplate:exit'(node) {

lib/rules/template-modifier-name-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
},
4040

4141
create(context) {
42-
const filename = context.filename ?? context.getFilename();
42+
const filename = context.filename;
4343
if (!filename.endsWith('.hbs')) {
4444
return {};
4545
}

lib/rules/template-no-action-modifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
create(context) {
4141
const firstOption = context.options[0];
4242
const allowlist = Array.isArray(firstOption) ? firstOption : firstOption?.allowlist || [];
43-
const sourceCode = context.sourceCode ?? context.getSourceCode();
43+
const sourceCode = context.sourceCode;
4444

4545
function checkForActionModifier(node) {
4646
if (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module.exports = {
9393
},
9494

9595
create(context) {
96-
const sourceCode = context.sourceCode || context.getSourceCode();
96+
const sourceCode = context.sourceCode;
9797

9898
return {
9999
GlimmerPathExpression(node) {

lib/rules/template-no-bare-strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ module.exports = {
175175
},
176176

177177
create(context) {
178-
const filename = context.filename ?? context.getFilename();
178+
const filename = context.filename;
179179
const isStrictMode = filename.endsWith('.gjs') || filename.endsWith('.gts');
180180

181181
const rawConfig = context.options[0];

0 commit comments

Comments
 (0)