Skip to content

Commit

Permalink
non-breaking approach
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Aug 22, 2023
1 parent a96dc3b commit 2bb7972
Show file tree
Hide file tree
Showing 12 changed files with 1,774 additions and 163 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,29 @@ module.exports = {
```

To correctly parse gjs/gts:
Do not set an override for the parser in the global config.
To use e.g. the typescript parser, the following should be used

```js
// .eslintrc.js
module.exports = {
plugins: ['ember'],
// parser: '@typescript-eslint/parser', <-- needs to be removed, or set the gts/gjs one
// so we could also have:
// parser: "eslint-plugin-ember/gts-parser",
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/base', // or typescript-eslint/recommended, must come before plugin:ember/recommended
'plugin:ember/recommended', // or other configuration
],
overrides: [
{
files: ['**/*.gts'],
extends: [
'plugin:ember/recommended-gjs',
]
},
{
files: ['**/*.gjs'],
extends: [
'plugin:ember/recommended-gjs',
]
}
],
rules: {
// override / enable optional rules
'ember/no-replace-test-comments': 'error'
Expand Down
41 changes: 41 additions & 0 deletions lib/config/recommended-gjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const rules = require('../recommended-rules');

module.exports = {
root: true,

parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},

env: {
browser: true,
es2020: true,
},

plugins: ['ember'],

rules,

overrides: [
/**
* We don't want to *always* have the preprocessor active,
* it's only relevant on gjs and gts files.
*
* Additionally, we need to declare a global (which is private API)
* so that ESLint doesn't report errors about the variable being undefined.
* While this is true, it's a temporary thing for babel to do further processing
* on -- and isn't relevant to user-land code.
*/
{
files: ['**/*.gts'],
parser: 'eslint-plugin-ember/gts-parser',
processor: 'ember/<noop>',
},
{
files: ['**/*.gjs'],
parser: 'eslint-plugin-ember/gjs-parser',
processor: 'ember/<noop>',
},
],
};
12 changes: 6 additions & 6 deletions lib/config/recommended.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rules = require('../recommended-rules');
const util = require('ember-template-imports/src/util');

module.exports = {
root: true,
Expand Down Expand Up @@ -28,12 +29,11 @@ module.exports = {
* on -- and isn't relevant to user-land code.
*/
{
files: ['**/*.gts'],
parser: require.resolve('../parsers/gts-parser'),
},
{
files: ['**/*.gjs'],
parser: require.resolve('../parsers/gjs-parser'),
files: ['**/*.gjs', '**/*.gts'],
processor: 'ember/<template>',
globals: {
[util.TEMPLATE_TAG_PLACEHOLDER]: 'readonly',
},
},
],
};
8 changes: 8 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

const requireIndex = require('requireindex');

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

module.exports = {
rules: requireIndex(`${__dirname}/rules`),
configs: requireIndex(`${__dirname}/config`),
utils: {
ember: require('./utils/ember'),
},
processors: {
// https://eslint.org/docs/developer-guide/working-with-plugins#file-extension-named-processor
'<template>': gjs,
'<noop>': noop,
},
};
Loading

0 comments on commit 2bb7972

Please sign in to comment.