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

ESLint 9 + flat configs #309

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
9 changes: 0 additions & 9 deletions files/__addonLocation__/.eslintignore

This file was deleted.

104 changes: 0 additions & 104 deletions files/__addonLocation__/.eslintrc.cjs

This file was deleted.

109 changes: 109 additions & 0 deletions files/__addonLocation__/_js_eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* npx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* npx eslint --inspect-config
*
*/
import globals from 'globals';
import js from '@eslint/js';

import ember from 'eslint-plugin-ember/recommended';
import imports from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier/recommended';
import n from 'eslint-plugin-n';

import babelParser from '@babel/eslint-parser';

const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
};

export default [
js.configs.recommended,
prettier,
ember.configs.base,
ember.configs.gjs,
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
},
},
{
files: ['**/*.{js,gjs}'],
languageOptions: {
parserOptions: esmParserOptions,
globals: {
...globals.browser,
},
},
},
{
files: ['**/*.{js,gjs,ts,gts}'],
plugins: {
import: imports,
},
rules: {
'import/extensions': ['error', 'always', { ignorePackages: true }],
},
},
/**
* CJS node files
*/
{
files: ['**/*.cjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
files: ['**/*.mjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: esmParserOptions,
globals: {
...globals.node,
},
},
},
];
136 changes: 136 additions & 0 deletions files/__addonLocation__/_ts_eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* npx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* npx eslint --inspect-config
*
*/
import globals from 'globals';
import js from '@eslint/js';

import ts from 'typescript-eslint';

import ember from 'eslint-plugin-ember/recommended';
import imports from 'eslint-plugin-import';

import prettier from 'eslint-plugin-prettier/recommended';
import n from 'eslint-plugin-n';

import babelParser from '@babel/eslint-parser';

const parserOptions = {
esm: {
js: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
},
ts: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
};

export default ts.config(
js.configs.recommended,
ember.configs.base,
ember.configs.gjs,
ember.configs.gts,
prettier,
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
ignores: ['dist/', 'declarations/', 'node_modules/', 'coverage/', '!**/.*'],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
},
},
{
files: ['**/*.{js,gjs}'],
languageOptions: {
parserOptions: parserOptions.esm.js,
globals: {
...globals.browser,
},
},
},
{
files: ['**/*.ts'],
languageOptions: {
parserOptions: parserOptions.esm.ts,
},
extends: [ember.configs.base, ...ts.configs.recommendedTypeChecked],
},
{
files: ['**/*.gts'],
languageOptions: {
parser: ember.parser,
parserOptions: parserOptions.esm.ts,
},
extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts],
},
{
files: ['**/*.{js,gjs,ts,gts}'],
plugins: {
import: imports,
},
rules: {
'import/extensions': ['error', 'always', { ignorePackages: true }],
},
},
/**
* CJS node files
*/
{
files: ['**/*.cjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
files: ['**/*.mjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: parserOptions.esm.js,
globals: {
...globals.node,
},
},
},
);
18 changes: 10 additions & 8 deletions files/__addonLocation__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,27 @@
"@types/ember__modifier": "^4.0.8",
"@types/ember__helper": "^4.0.5",
"@types/ember__routing": "^4.0.19",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",<% } %>
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",<% } %>
"@rollup/plugin-babel": "^6.0.4",
"babel-plugin-ember-template-compilation": "^2.2.5",
"concurrently": "^8.2.2",
"ember-source": "^<%= latestEmberSource %>",
"ember-template-lint": "^6.0.0",<% if (packageManager === 'npm') { %>
"ember-eslint-parser": "^0.4.2",
<% } %>"eslint": "^8.56.0",
<% } %>"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^12.0.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-ember": "^12.3.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.3.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"eslint-plugin-prettier": "^5.2.1",
"globals": "15.12.0",
"prettier": "^3.3.3",
"prettier-plugin-ember-template-tag": "^2.0.2",
"rollup": "^4.16.4"<% if (!isExistingMonorepo) { %>,
"rollup-plugin-copy": "^3.5.0"<% } %><% if (typescript) { %>,
"typescript": "^5.4.5"<% } %>
"typescript": "^5.4.5",
"typescript-eslint": "8.13.0"<% } %>
},
"ember": {
"edition": "octane"
Expand Down
Loading
Loading