Skip to content

Commit

Permalink
Merge pull request #2191 from NullVoxPopuli/better-gjs-exports
Browse files Browse the repository at this point in the history
Provide better gjs/gts config support for eslint 9
  • Loading branch information
NullVoxPopuli authored Oct 21, 2024
2 parents 8e5aaca + f0ca88e commit f040d90
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
26 changes: 26 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,30 @@ module.exports = [
'unicorn/filename-case': 'off',
},
},
{
files: ['**/*.mjs'],
languageOptions: {
parser: babelEslintParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 2022,
babelOptions: {
configFile: require.resolve('./.babelrc'),
},
},
},
rules: {
// Extensions are required in ESM
'import/extensions': ['error', 'ignorePackages'],
// These don't appear to work correctly
// All these throw on the import of a dependency
'import/namespace': 'off',
'import/no-deprecated': 'off',
'import/default': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-unresalved': 'off',
'import/no-missing-import': 'off',
},
},
];
63 changes: 63 additions & 0 deletions lib/recommended.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import emberPlugin from './index.js';
import baseRules from './recommended-rules.js';
import gjsRules from './recommended-rules-gjs.js';
import gtsRules from './recommended-rules-gts.js';
import emberParser from 'ember-eslint-parser';

export const plugin = emberPlugin;
export const parser = emberParser;

export const base = {
files: ['**/*.{js,ts}'],
plugins: { ember: emberPlugin },
rules: {
...baseRules,
},
};

export const gjs = {
plugins: { ember: emberPlugin },
files: ['**/*.gjs'],
languageOptions: {
parser: emberParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
// babel config options should be supplied in the consuming project
},
},
processor: 'ember/noop',
rules: {
...base.rules,
...gjsRules,
},
};

export const gts = {
plugins: { ember: emberPlugin },
files: ['**/*.gts'],
languageOptions: {
parser: emberParser,
parserOptions: {
extraFileExtensions: ['.gts'],
},
// parser options should be supplied in the consuming project
},
processor: 'ember/noop',
rules: {
...base.rules,
...gtsRules,
},
};

export default {
// Helpful utility exports
plugin,
parser,
// Recommended config sets
configs: {
base,
gjs,
gts,
},
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"license": "MIT",
"exports": {
".": "./lib/index.js",
"./recommended": {
"import": "./lib/recommended.mjs"
},
"./configs/*": "./lib/config/*.js"
},
"main": "./lib/index.js",
Expand Down

0 comments on commit f040d90

Please sign in to comment.