From 8d2641dc5908774fd734d57ec8c11962aaba47f5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:39:20 -0400 Subject: [PATCH 1/2] Update the linting packages and the eslint config --- files/__addonLocation__/.eslintrc.cjs | 88 +++++++++++++++++++-------- files/__addonLocation__/package.json | 16 ++--- 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/files/__addonLocation__/.eslintrc.cjs b/files/__addonLocation__/.eslintrc.cjs index 639c4b9..a490896 100644 --- a/files/__addonLocation__/.eslintrc.cjs +++ b/files/__addonLocation__/.eslintrc.cjs @@ -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', @@ -62,7 +94,11 @@ module.exports = { node: true, }, plugins: ['n'], - extends: ['plugin:n/recommended'], + extends: [ + 'eslint:recommended', + 'plugin:n/recommended', + 'plugin:prettier/recommended', + ], }, ], }; diff --git a/files/__addonLocation__/package.json b/files/__addonLocation__/package.json index 226978f..bd44de6 100644 --- a/files/__addonLocation__/package.json +++ b/files/__addonLocation__/package.json @@ -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"<% } %> From 74c7ae39eed53dbc7c3390f37933c93e04ac466f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:14:26 -0400 Subject: [PATCH 2/2] Try special casing npm --- files/__addonLocation__/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/__addonLocation__/package.json b/files/__addonLocation__/package.json index bd44de6..28e4fb3 100644 --- a/files/__addonLocation__/package.json +++ b/files/__addonLocation__/package.json @@ -72,8 +72,9 @@ "@rollup/plugin-babel": "^6.0.4", "babel-plugin-ember-template-compilation": "^2.2.2", "concurrently": "^8.2.2", - "ember-template-lint": "^6.0.0", - "eslint": "^8.56.0", + "ember-template-lint": "^6.0.0",<% if (packageManager === 'npm') { %> + "ember-eslint-parser": "^0.4.2", + <% } %>"eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-ember": "^12.0.2", "eslint-plugin-import": "^2.29.1",