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

[ENHANCEMENT] Use a flat ESLint config file in the app blueprint #10451

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions blueprints/app/files/.eslintignore

This file was deleted.

67 changes: 0 additions & 67 deletions blueprints/app/files/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion blueprints/app/files/.prettierrc.js
Expand Up @@ -3,7 +3,7 @@
module.exports = {
overrides: [
{
files: '*.{js,ts}',
files: '*.{cjs,js,mjs,ts}',
options: {
singleQuote: true,
},
Expand Down
69 changes: 69 additions & 0 deletions blueprints/app/files/eslint.config.mjs
Copy link
Contributor

Choose a reason for hiding this comment

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

imo, we should probably include gjs/gts support in here by default, since there is no cost to having config for gjs/gts if folks aren't using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you provide a todo list for this? I know the recommended flat config of eslint-plugin-ember already brings in the correct parser, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to use recommended-gjs or recommended-gts when needed it seems?

Copy link
Contributor

Choose a reason for hiding this comment

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

and set the parser, per the readme here:
https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs

this'll actually solve a lot of problems folks have had with gjs/gts, because there are bugs when a parser is specified outside of overrides with the non-flat config

@@ -0,0 +1,69 @@
<% if (!typescript) { %>import babelEslintParser from '@babel/eslint-parser';
<% } %>import eslint from '@eslint/js';
import pluginEmberRecommended from 'eslint-plugin-ember/configs/recommended';
import pluginNode from 'eslint-plugin-n';
import pluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import pluginQunitRecommended from 'eslint-plugin-qunit/configs/recommended';
<% if (typescript) { %>import typescriptEslint from 'typescript-eslint';
<% } else { %>import globals from 'globals';
<% } %>
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [<% if (!typescript) { %>
// Babel:
{
languageOptions: {
globals: globals.browser,
parser: babelEslintParser,
parserOptions: {
babelOptions: {
plugins: [
[
'@babel/plugin-proposal-decorators',
{ decoratorsBeforeExport: true },
],
],
},
ecmaVersion: 'latest',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

latest should be the default when using a flat config, so this can go? Not sure, because this one is under parserOptions.

requireConfigFile: false,
sourceType: 'module',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

module should be the default when using a flat config, so this can go? Not sure, because this one is under parserOptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

sourceType is determined by the package.json type field, so I think we still need this since we lie about what type of package our projects are (CJS)

},
},
},
<% } %>
// ESLint:
eslint.configs.recommended,

// Ember:
...pluginEmberRecommended,
<% if (typescript) { %>
// TypeScript:
...typescriptEslint.configs.recommended.map((config) => ({
...config,
files: ['**/*.ts'],
})),
<% } %>
// Node:
{
...pluginNode.configs['flat/recommended-script'],
files: [
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js',
'*.js',
],
},
{
...pluginNode.configs['flat/recommended-module'],
files: ['*.mjs'],
},

// Qunit:
{
...pluginQunitRecommended,
files: ['tests/**/*-test.{js,ts}'],
},

// Prettier:
pluginPrettierRecommended,
];
9 changes: 5 additions & 4 deletions blueprints/app/files/package.json
Expand Up @@ -35,6 +35,7 @@
"@embroider/compat": "^3.4.5",
"@embroider/core": "^3.4.5",
"@embroider/webpack": "^3.2.2<% } %>",
"@eslint/js": "^8.57.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2<% if (typescript) { %>",
"@glint/environment-ember-loose": "^1.3.0",
Expand Down Expand Up @@ -67,9 +68,7 @@
"@types/ember__test": "^4.0.6",
"@types/ember__utils": "^4.0.7",
"@types/qunit": "^2.19.10",
"@types/rsvp": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0<% } %>",
"@types/rsvp": "^4.0.9<% } %>",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.2.2",
"ember-auto-import": "^2.7.2",
Expand Down Expand Up @@ -98,6 +97,7 @@
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-qunit": "^8.1.1",
"globals": "^14.0.0",
"loader.js": "^4.7.0",
"prettier": "^3.2.5",
"qunit": "^2.20.1",
Expand All @@ -106,7 +106,8 @@
"stylelint-config-standard": "^34.0.0",
"stylelint-prettier": "^4.1.0",
"tracked-built-ins": "^3.3.0<% if (typescript) { %>",
"typescript": "^5.3.3<% } %>",
"typescript": "^5.3.3",
"typescript-eslint": "^7.3.1<% } %>",
"webpack": "^5.90.3"
},
"engines": {
Expand Down