Skip to content

Commit

Permalink
Update the linting packages and the eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Apr 25, 2024
1 parent 8b2a311 commit 8d2641d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 34 deletions.
88 changes: 62 additions & 26 deletions files/__addonLocation__/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,83 @@

module.exports = {
root: true,
parser: '<%= typescript ? '@typescript-eslint/parser' : '@babel/eslint-parser' %>',
parserOptions: {
ecmaVersion: 'latest',<% if (!typescript) { %>
sourceType: 'module',
babelOptions: {
root: __dirname,
},<% } %>
},
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true,
},
rules: {},
// Only use overrides
// https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs
overrides: [
{
files: ['**/*.js'<%= typescript ? ", '**/*.ts'" : '' %>],
env: { browser: true },
parser: '<%= typescript ? '@typescript-eslint/parser' : '@babel/eslint-parser' %>',
parserOptions: {
ecmaVersion: 'latest',<% if (!typescript) { %>
sourceType: 'module',
babelOptions: {
root: __dirname,
},<% } %>
},
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
<% if (typescript) { %> // ts files
{
files: ['**/*.ts', '**/*.gts'],
files: ['**/*.ts'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
// require relative imports use full extensions
{
files: ['src/**/*.{js,ts,gjs,gts}'],
files: ['**/*.gts'],
parser: 'ember-eslint-parser',
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gts',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
<% } else { %> // require relative imports use full extensions
{
files: ['src/**/*.{js,gjs}'],
<% } %> {
files: ['**/*.gjs'],
parser: 'ember-eslint-parser',
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gjs',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
<% } %> // node files
// node files
{
files: [
'./.eslintrc.cjs',
Expand All @@ -62,7 +94,11 @@ module.exports = {
node: true,
},
plugins: ['n'],
extends: ['plugin:n/recommended'],
extends: [
'eslint:recommended',
'plugin:n/recommended',
'plugin:prettier/recommended',
],
},
],
};
16 changes: 8 additions & 8 deletions files/__addonLocation__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@
"@types/ember__modifier": "^4.0.8",
"@types/ember__helper": "^4.0.5",
"@types/ember__routing": "^4.0.19",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",<% } %>
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",<% } %>
"@rollup/plugin-babel": "^6.0.4",
"babel-plugin-ember-template-compilation": "^2.2.2",
"concurrently": "^8.2.2",
"ember-template-lint": "^5.13.0",
"ember-template-lint": "^6.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^11.12.0",
"eslint-plugin-ember": "^12.0.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.1",
"prettier-plugin-ember-template-tag": "^1.1.0",
"eslint-plugin-n": "^17.3.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"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"<% } %>
Expand Down

4 comments on commit 8d2641d

@BoussonKarel
Copy link
Contributor

Choose a reason for hiding this comment

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

You updated prettier-plugin-ember-template-tag here, but not in the workspace root package.json.

This results in my linting command formatting stuff and my VSCode complaining it should be formatted differently.

E.g. the linting command chooses this:

const x = <template><div id='someElement' /></template>;

But my IDE (vscode) wants this:

const x = <template>
  <div id='someElement' />
</template>;

@NullVoxPopuli
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do you have prettier removed from eslint and running separately?
have you restarted your editor extensions? (VSCode does not pick up on config or dependency changes automatically)

@NullVoxPopuli
Copy link
Collaborator Author

@NullVoxPopuli NullVoxPopuli commented on 8d2641d Aug 23, 2024

Choose a reason for hiding this comment

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

oh i see! the version is ancient! thanks for your PR!

@BoussonKarel
Copy link
Contributor

Choose a reason for hiding this comment

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

I created a PR for this
#295

Please sign in to comment.