forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-require-strict-mode.js
More file actions
44 lines (40 loc) · 1.19 KB
/
template-require-strict-mode.js
File metadata and controls
44 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const ERROR_MESSAGE =
'Templates are required to be in strict mode. Consider refactoring to template tag format.';
function isStrictModeFile(filePath) {
return filePath?.endsWith('.gjs') || filePath?.endsWith('.gts');
}
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'require templates to be in strict mode',
category: 'Best Practices',
recommended: false,
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-require-strict-mode.md',
templateMode: 'loose',
},
fixable: null,
schema: [],
messages: {},
originallyFrom: {
name: 'ember-template-lint',
rule: 'lib/rules/require-strict-mode.js',
docs: 'docs/rule/require-strict-mode.md',
tests: 'test/unit/rules/require-strict-mode-test.js',
},
},
create(context) {
const filePath = context.getFilename ? context.getFilename() : context.filename;
return {
'GlimmerTemplate:exit'(node) {
if (!isStrictModeFile(filePath)) {
context.report({
node,
message: ERROR_MESSAGE,
});
}
},
};
},
};