Skip to content

Extract rule: template-require-strict-mode#2613

Open
NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-require-strict-mode
Open

Extract rule: template-require-strict-mode#2613
NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-require-strict-mode

Conversation

@NullVoxPopuli
Copy link
Contributor

Split from #2371.

Copy link

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: template-require-strict-mode (PR #2613)

Comparison with ember-template-lint source

General correctness:

  1. Detection mechanism differs: The original ETL rule uses this.isStrictMode which is a property set by the ETL framework based on how the template was parsed. The ESLint version checks the file extension (filePath.endsWith('.hbs')). This is a reasonable approximation but has edge cases:

    • Files without extensions or with unusual extensions would not be flagged.
    • The templateMode: 'loose' in the meta should already restrict this rule to .hbs files via the parser, so the filename check may be redundant (or the templateMode may not be fully enforced yet). Worth verifying.
  2. messages is empty: The rule uses inline message in context.report() instead of messageId. Minor style inconsistency.

  3. Test gap: The hbs test suite has no invalid cases. The comment says invalid: [] for the hbs parser. This is odd — since this rule is specifically designed to flag .hbs files, the hbs parser tests should have invalid cases. However, it seems the hbs parser might not set filename context the same way, making it difficult to test. The gjs tests do include an invalid case with filename: 'hello.hbs' which covers the core logic.

  4. templateMode: 'loose' correctness: Setting templateMode: 'loose' is correct since this rule only applies to loose-mode templates. However, the valid test for the gjs parser (filename: 'hello.gjs') will still run the rule visitor — it just won't trigger because the filename check prevents reporting. This is fine functionally.

Scope analysis (gjs/gts):

Not applicable. This rule checks file-level metadata (filename/mode), not template content.

Summary: Straightforward migration. The filename-based detection is a reasonable approach. No blocking issues.

🤖 Automated review comparing with ember-template-lint source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants