embroider-build/addon-blueprint

Add linter rule to require that relative imports use full extensions

lukemelia opened this issue · 3 comments

The addon build expects relative imports to use full extensions (.ts, .gts, .js, .hbs). This can be easy for an Ember developer to forget since it is not a requirement in ember-cli-built apps. It would be helpful to have a lint rule enabled by default that errors when a relative import is used without an extension.

I have such a rule already in place in a private repo. Also one for enforcing relative imports (instead of self-referencing your package name, which worked in v1 addons). And both are auto-fixable. I should be able to extract and open-source them hopefully soon...

found it:

{
	files: ['src/**/*.{js,ts,gjs,gts}'],
	rules: {
		'import/extensions': ['error', 'always', { ignorePackages: true }],

	},
},

https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md

anyone want to PR a good eslint-plugin-import setup to the addon-blueprint here?

import/extensions from eslint-plugin-import works great with one caveat - it does not support type-only imports.

Here is an issue to track progress import-js/eslint-plugin-import#2530