Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better gjs/gts config support for eslint 9 #2191

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

new public import, only available via import, not require

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