Skip to content

Commit

Permalink
use custom parser for gts/gjs
Browse files Browse the repository at this point in the history
bonus:
 * enables type aware lints
 * prettier eslint plugin (with template tag prettier plugin) will just work for gts/gjs
 * can detect unused block params in templates
 * can detect undef vars in PathExpression
 * can add eslint directive comments in mustache or html
disadvantage:
* prettier will not work without template tag prettier plugin for gts/gjs files
  • Loading branch information
patricklx committed Oct 31, 2023
1 parent 199ae8e commit 8b53ff0
Show file tree
Hide file tree
Showing 15 changed files with 956 additions and 1,104 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ module.exports = {
};
```

## gts/gjs

lint files having `First-Class Component Templates`

learn more [here](https://github.com/ember-template-imports/ember-template-imports)

```js
// .eslintrc.js
module.exports = {
overrides: [
{
files: ['**/*.gts', '**/*.gjs'],
parser: 'eslint-plugin-ember/gjs-gts-parser',
}
],
};
```

## 🧰 Configurations

| | Name | Description |
Expand Down
9 changes: 3 additions & 6 deletions lib/config/recommended.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const rules = require('../recommended-rules');
const util = require('ember-template-imports/src/util');

module.exports = {
root: true,
Expand Down Expand Up @@ -29,11 +28,9 @@ module.exports = {
* on -- and isn't relevant to user-land code.
*/
{
files: ['**/*.gjs', '**/*.gts'],
processor: 'ember/<template>',
globals: {
[util.TEMPLATE_TAG_PLACEHOLDER]: 'readonly',
},
files: ['**/*.gts', '**/*.gjs'],
parser: 'eslint-plugin-ember/gjs-gts-parser',
processor: 'ember/<noop>',
},
],
};
7 changes: 2 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

const requireIndex = require('requireindex');

const gjs = require('./preprocessors/glimmer');
const noop = require('./preprocessors/noop');

module.exports = {
rules: requireIndex(`${__dirname}/rules`),
Expand All @@ -12,8 +11,6 @@ module.exports = {
},
processors: {
// https://eslint.org/docs/developer-guide/working-with-plugins#file-extension-named-processor
'.gjs': gjs,
'.gts': gjs,
'<template>': gjs,
'<noop>': noop,
},
};
Loading

0 comments on commit 8b53ff0

Please sign in to comment.