Skip to content

Commit

Permalink
Add ESLint rule to require that relative imports use full extensions
Browse files Browse the repository at this point in the history
Use import ESLint plugin
  • Loading branch information
SergeAstapov committed Mar 29, 2024
1 parent 8b7e2be commit d8c30cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion files/__addonLocation__/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
root: __dirname,
},<% } %>
},
plugins: ['ember'],
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
Expand All @@ -32,6 +32,20 @@ module.exports = {
// Add any custom rules here
},
},
// require relative imports use full extensions
{
files: ['src/**/*.{js,ts,gjs,gts}'],
rules: {
'import/extensions': ['error', 'always', { ignorePackages: true }],
},
},
<% } else { %> // require relative imports use full extensions
{
files: ['src/**/*.{js,gjs}'],
rules: {
'import/extensions': ['error', 'always', { ignorePackages: true }],
},
},
<% } %> // node files
{
files: [
Expand Down
1 change: 1 addition & 0 deletions files/__addonLocation__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^11.12.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.1",
Expand Down

0 comments on commit d8c30cf

Please sign in to comment.