Skip to content

Commit 83cbfa3

Browse files
NullVoxPopuliclaude
andcommitted
Address PR review feedback
- Revert recommended.mjs to original (cannot change recommended config) - Keep noop processor unchanged; export template-lint-disable as a separate processor (ember/template-lint-disable) to avoid breaking existing gjs/gts users - Wire hbs files to use the new processor by default in base configs (hbs had no prior config, so this is additive) - Move hbs tests to a separate hbs-parser-test.js file - Update gjs template-lint-disable tests to explicitly use the new processor via initESLintWithTemplateLintDisable() Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 51ff450 commit 83cbfa3

6 files changed

Lines changed: 166 additions & 149 deletions

File tree

lib/config-legacy/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
{
2727
files: ['**/*.hbs'],
2828
parser: 'ember-eslint-parser/hbs',
29-
processor: 'ember/noop',
29+
processor: 'ember/template-lint-disable',
3030
},
3131
],
3232
};

lib/config/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ module.exports = [
2323
languageOptions: {
2424
parser: emberEslintParserHbs,
2525
},
26-
processor: 'ember/noop',
26+
processor: 'ember/template-lint-disable',
2727
},
2828
];

lib/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const requireIndex = require('requireindex');
4+
const noop = require('ember-eslint-parser/noop');
45
const templateLintDisableProcessor = require('./processors/template-lint-disable');
56
const pkg = require('../package.json'); // eslint-disable-line import/extensions
67

@@ -16,6 +17,7 @@ module.exports = {
1617
},
1718
processors: {
1819
// https://eslint.org/docs/developer-guide/working-with-plugins#file-extension-named-processor
19-
noop: templateLintDisableProcessor,
20+
noop,
21+
'template-lint-disable': templateLintDisableProcessor,
2022
},
2123
};

lib/recommended.mjs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import baseRules from './recommended-rules.js';
33
import gjsRules from './recommended-rules-gjs.js';
44
import gtsRules from './recommended-rules-gts.js';
55
import emberParser from 'ember-eslint-parser';
6-
import emberParserHbs from 'ember-eslint-parser/hbs';
76

87
export const plugin = emberPlugin;
98
export const parser = emberParser;
10-
export const hbsParser = emberParserHbs;
119

1210
export const base = {
1311
name: 'ember:base',
@@ -55,29 +53,14 @@ export const gts = {
5553
},
5654
};
5755

58-
export const hbs = {
59-
name: 'ember:hbs',
60-
plugins: { ember: emberPlugin },
61-
files: ['**/*.hbs'],
62-
languageOptions: {
63-
parser: emberParserHbs,
64-
},
65-
processor: 'ember/noop',
66-
rules: {
67-
...base.rules,
68-
},
69-
};
70-
7156
export default {
7257
// Helpful utility exports
7358
plugin,
7459
parser,
75-
hbsParser,
7660
// Recommended config sets
7761
configs: {
7862
base,
7963
gjs,
8064
gts,
81-
hbs,
8265
},
8366
};

tests/lib/rules-preprocessor/gjs-gts-parser-test.js

Lines changed: 34 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const { writeFileSync, readFileSync } = require('node:fs');
1313
const { join } = require('node:path');
1414

1515
const gjsGtsParser = require.resolve('ember-eslint-parser');
16-
const hbsParser = require.resolve('ember-eslint-parser/hbs');
1716

1817
/**
1918
* Helper function which creates ESLint instance with enabled/disabled autofix feature.
@@ -888,9 +887,35 @@ describe('multiple tokens in same file', () => {
888887
});
889888
});
890889

890+
function initESLintWithTemplateLintDisable() {
891+
return new ESLint({
892+
ignore: false,
893+
useEslintrc: false,
894+
plugins: { ember: plugin },
895+
overrideConfig: {
896+
root: true,
897+
env: {
898+
browser: true,
899+
},
900+
parserOptions: {
901+
ecmaVersion: 2022,
902+
sourceType: 'module',
903+
},
904+
parser: gjsGtsParser,
905+
plugins: ['ember'],
906+
processor: 'ember/template-lint-disable',
907+
rules: {
908+
'no-undef': 'error',
909+
'no-unused-vars': 'error',
910+
quotes: ['error', 'single'],
911+
},
912+
},
913+
});
914+
}
915+
891916
describe('supports template-lint-disable directive', () => {
892917
it('disables all rules on the next line with mustache comment', async () => {
893-
const eslint = initESLint();
918+
const eslint = initESLintWithTemplateLintDisable();
894919
const code = `
895920
<template>
896921
<div>
@@ -906,7 +931,7 @@ describe('supports template-lint-disable directive', () => {
906931
});
907932

908933
it('disables all rules on the next line with mustache block comment', async () => {
909-
const eslint = initESLint();
934+
const eslint = initESLintWithTemplateLintDisable();
910935
const code = `
911936
<template>
912937
<div>
@@ -921,7 +946,7 @@ describe('supports template-lint-disable directive', () => {
921946
});
922947

923948
it('disables a specific rule by eslint rule name', async () => {
924-
const eslint = initESLint();
949+
const eslint = initESLintWithTemplateLintDisable();
925950
const code = `
926951
<template>
927952
<div>
@@ -940,7 +965,7 @@ describe('supports template-lint-disable directive', () => {
940965
});
941966

942967
it('only disables the next line, not subsequent lines', async () => {
943-
const eslint = initESLint();
968+
const eslint = initESLintWithTemplateLintDisable();
944969
const code = `
945970
<template>
946971
<div>
@@ -958,7 +983,7 @@ describe('supports template-lint-disable directive', () => {
958983
});
959984

960985
it('does not suppress unrelated rules when a specific rule is named', async () => {
961-
const eslint = initESLint();
986+
const eslint = initESLintWithTemplateLintDisable();
962987
const code = `
963988
<template>
964989
<div>
@@ -975,7 +1000,7 @@ describe('supports template-lint-disable directive', () => {
9751000
});
9761001

9771002
it('supports template-lint rule name format (maps to ember/ prefix)', async () => {
978-
const eslint = initESLint();
1003+
const eslint = initESLintWithTemplateLintDisable();
9791004
const code = `
9801005
<template>
9811006
<div>
@@ -990,7 +1015,7 @@ describe('supports template-lint-disable directive', () => {
9901015
});
9911016

9921017
it('supports multiple rule names', async () => {
993-
const eslint = initESLint();
1018+
const eslint = initESLintWithTemplateLintDisable();
9941019
const code = `
9951020
<template>
9961021
<div>
@@ -1005,7 +1030,7 @@ describe('supports template-lint-disable directive', () => {
10051030
});
10061031

10071032
it('works with multiple disable comments in the same file', async () => {
1008-
const eslint = initESLint();
1033+
const eslint = initESLintWithTemplateLintDisable();
10091034
const code = `
10101035
<template>
10111036
<div>
@@ -1022,123 +1047,3 @@ describe('supports template-lint-disable directive', () => {
10221047
});
10231048
});
10241049

1025-
function initHbsESLint() {
1026-
return new ESLint({
1027-
ignore: false,
1028-
useEslintrc: false,
1029-
plugins: { ember: plugin },
1030-
overrideConfig: {
1031-
root: true,
1032-
parserOptions: {
1033-
ecmaVersion: 2022,
1034-
sourceType: 'module',
1035-
},
1036-
plugins: ['ember'],
1037-
overrides: [
1038-
{
1039-
files: ['**/*.hbs'],
1040-
parser: hbsParser,
1041-
processor: 'ember/noop',
1042-
rules: {
1043-
'ember/template-no-bare-strings': 'error',
1044-
},
1045-
},
1046-
],
1047-
},
1048-
});
1049-
}
1050-
1051-
describe('supports template-lint-disable directive in hbs files', () => {
1052-
it('disables all rules on the next line with mustache comment', async () => {
1053-
const eslint = initHbsESLint();
1054-
const code = `<div>
1055-
{{! template-lint-disable }}
1056-
Hello world
1057-
</div>`;
1058-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1059-
const resultErrors = results.flatMap((result) => result.messages);
1060-
expect(resultErrors).toHaveLength(0);
1061-
});
1062-
1063-
it('disables all rules on the next line with mustache block comment', async () => {
1064-
const eslint = initHbsESLint();
1065-
const code = `<div>
1066-
{{!-- template-lint-disable --}}
1067-
Hello world
1068-
</div>`;
1069-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1070-
const resultErrors = results.flatMap((result) => result.messages);
1071-
expect(resultErrors).toHaveLength(0);
1072-
});
1073-
1074-
it('only disables the next line, not subsequent lines', async () => {
1075-
const eslint = initHbsESLint();
1076-
const code = `{{! template-lint-disable }}
1077-
<div>Hello world</div>
1078-
<div>Bare string here too</div>`;
1079-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1080-
const resultErrors = results.flatMap((result) => result.messages);
1081-
// Line 2 "Hello world" suppressed, but line 3 "Bare string here too" should still error
1082-
expect(resultErrors).toHaveLength(1);
1083-
expect(resultErrors[0].line).toBe(3);
1084-
});
1085-
1086-
it('disables a specific rule by name', async () => {
1087-
const eslint = initHbsESLint();
1088-
const code = `<div>
1089-
{{! template-lint-disable ember/template-no-bare-strings }}
1090-
Hello world
1091-
</div>`;
1092-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1093-
const resultErrors = results.flatMap((result) => result.messages);
1094-
expect(resultErrors).toHaveLength(0);
1095-
});
1096-
1097-
it('supports template-lint rule name format (maps to ember/ prefix)', async () => {
1098-
const eslint = initHbsESLint();
1099-
const code = `<div>
1100-
{{! template-lint-disable no-bare-strings }}
1101-
Hello world
1102-
</div>`;
1103-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1104-
const resultErrors = results.flatMap((result) => result.messages);
1105-
expect(resultErrors).toHaveLength(0);
1106-
});
1107-
1108-
it('does not suppress unrelated rules when a specific rule is named', async () => {
1109-
const eslint = initHbsESLint();
1110-
const code = `<div>
1111-
{{! template-lint-disable ember/template-no-html-comments }}
1112-
Hello world
1113-
</div>`;
1114-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1115-
const resultErrors = results.flatMap((result) => result.messages);
1116-
// no-bare-strings should still fire since we only disabled no-html-comments
1117-
expect(resultErrors).toHaveLength(1);
1118-
expect(resultErrors[0].ruleId).toBe('ember/template-no-bare-strings');
1119-
});
1120-
1121-
it('works with multiple disable comments in the same file', async () => {
1122-
const eslint = initHbsESLint();
1123-
const code = `<div>
1124-
{{! template-lint-disable }}
1125-
Hello world
1126-
{{! template-lint-disable }}
1127-
Another bare string
1128-
</div>`;
1129-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1130-
const resultErrors = results.flatMap((result) => result.messages);
1131-
expect(resultErrors).toHaveLength(0);
1132-
});
1133-
1134-
it('bare strings without disable comment still trigger errors', async () => {
1135-
const eslint = initHbsESLint();
1136-
const code = `<div>
1137-
Hello world
1138-
</div>`;
1139-
const results = await eslint.lintText(code, { filePath: 'my-template.hbs' });
1140-
const resultErrors = results.flatMap((result) => result.messages);
1141-
expect(resultErrors).toHaveLength(1);
1142-
expect(resultErrors[0].ruleId).toBe('ember/template-no-bare-strings');
1143-
});
1144-
});

0 commit comments

Comments
 (0)