diff --git a/files/__addonLocation__/.eslintrc.cjs b/files/__addonLocation__/.eslintrc.cjs index 53844836..639c4b9b 100644 --- a/files/__addonLocation__/.eslintrc.cjs +++ b/files/__addonLocation__/.eslintrc.cjs @@ -10,7 +10,7 @@ module.exports = { root: __dirname, },<% } %> }, - plugins: ['ember'], + plugins: ['ember', 'import'], extends: [ 'eslint:recommended', 'plugin:ember/recommended', @@ -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: [ diff --git a/files/__addonLocation__/package.json b/files/__addonLocation__/package.json index a81736c0..84f9c8e6 100644 --- a/files/__addonLocation__/package.json +++ b/files/__addonLocation__/package.json @@ -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", diff --git a/tests/fixtures/default/my-addon/src/components/template-import.gjs b/tests/fixtures/default/my-addon/src/components/template-import.gjs index 063a3e6e..04f03636 100644 --- a/tests/fixtures/default/my-addon/src/components/template-import.gjs +++ b/tests/fixtures/default/my-addon/src/components/template-import.gjs @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import TemplateOnly from './template-only'; +import TemplateOnly from './template-only.js'; import { on } from '@ember/modifier'; export default class TemplateImport extends Component { diff --git a/tests/fixtures/default/my-addon/src/components/template-only.js b/tests/fixtures/default/my-addon/src/components/template-only.js new file mode 100644 index 00000000..fa850535 --- /dev/null +++ b/tests/fixtures/default/my-addon/src/components/template-only.js @@ -0,0 +1,3 @@ +import templateOnly from '@ember/component/template-only'; + +export default templateOnly(); diff --git a/tests/fixtures/typescript/my-addon/src/components/template-import.gts b/tests/fixtures/typescript/my-addon/src/components/template-import.gts index 7906ac8e..443f08ec 100644 --- a/tests/fixtures/typescript/my-addon/src/components/template-import.gts +++ b/tests/fixtures/typescript/my-addon/src/components/template-import.gts @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import TemplateOnly from './template-only'; +import TemplateOnly from './template-only.ts'; import AnotherGts from './another-gts.gts'; // N.B. relative imports inside a v2 addon should have explicit file extensions (this is consistent with how node treats ES modules) import { on } from '@ember/modifier'; import { action } from '@ember/object'; diff --git a/tests/smoke-tests/--typescript.test.ts b/tests/smoke-tests/--typescript.test.ts index b49009d2..a808189a 100644 --- a/tests/smoke-tests/--typescript.test.ts +++ b/tests/smoke-tests/--typescript.test.ts @@ -85,8 +85,6 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) { "index.js", "index.js.map", "services", - "template-only-B8yJqW69.js", - "template-only-B8yJqW69.js.map", "template-registry.js", "template-registry.js.map", ]