Support `<template>` (no-undef, etc)
Per RFC: https://github.com/emberjs/rfcs/pull/779
Overall plan, and maybe this is silly, but:
- for *gjs and *gts files, use a parser plugin, similar to eslint-plugin-markdown
Supports parsing <template> and discovering if tokens are violating no-undef, etc
Something to keep an eye on in the future:
- https://github.com/eslint/eslint/issues/13481
Jest: "global" coverage threshold for branches (96%) not met: 95.98%
so close. lol
Green!
And can you talk about the timeline given that the RFC hasn't been approved yet? We don't want to merge support for a feature that hasn't been approved yet, correct?
It's now in final comment period! 🎉
Can you explain the semver implications of this PR (aside from dropping support for old Node/ESLint versions which we will do separately/regardless)?
The capabilities (I think) are only additive, and no one expecting semver guarantees is currently using gjs/gts, so once people start to author gjs/gts, they'll have ESLint run on those files (currently ESLint skips those files).
Just tried this in a real project over here:
- https://github.com/NullVoxPopuli/limber/pull/392
- with: https://github.com/NullVoxPopuli/eslint-configs/pull/166
And there are errors -- so it's possible I've misconfigured the tests, or have missed something in my eslint configs, so.. fyi, I guess.
I'll report back when I can successfully run eslint with gjs/gts in a real project
Will unused variable detection come into play at all here (this PR or future PR)? There's an ESLint API for helping the no-unused-vars rule detect if variables are used, e.g. in the react/jsx-uses-var rule (implementation).
@bmish we don't need to worry about unused vars in JS because eslint takes care of it (eslint sees the raw format, rather than the <template> stuff) :tada:
Good news! tested this on a project with gjs -- things work, which is nice.
const one = 1;
const two = 2;
<template>
{{one}}
</template>
❯ yarn/pnpm/npm lint:js --fix
$ eslint . --cache --fix
<repo>/app/components/test.gjs
2:7 error 'two' is assigned a value but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)}
Bad news is that prettier doesn't know how to parse gjs, so to lint gjs, I had to remove:
'plugin:prettier/recommended',
from my config.
So, I think that means we need to PR parser support to prettier
Here is a more robust solution:
adding this entry to the app + addon blueprint's .eslintrc.js config:
{
files: ['**/*.gjs', '**/*.gts'],
rules: {
'prettier/prettier': 'off',
}
},
Can you merge/rebase the latest master?
Rebased