-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import/extensions doesn't work for require('./file-without-extension') #1230
Comments
changing
produces the expected linting error about the extension. So seems this rule is only implemented for import statements rather than require statements too. |
For the use case for why they should be for require statements too:
The result of the above is a When the extension is provided, the correct type information is achieved. |
The bullet points seem like a major flaw in both vscode and typescript, since omitting the extension is a best practice. Hopefully issues have been filed for those. Separately, we should lint import and require statements both whenever possible, for every rule - so this is a good fix to make. |
agreed, thanks, looking forward to it |
It seems better to have a helper to generate callbacks for module.exports = {
create(context) {
return addForGenericImport({
... // other callbacks
}, (source, node) => {
// callbacks for ImportDeclaration, static require CallExpression, ExportNamedDeclaration, ExportAllDeclaration, etc
}),
}
} Actually most rules miss How do you think? @ljharb |
A commonly used helper seems like a good idea. |
See reproduction details at https://github.com/balupton/eslint-issue-import-extensions
get started:
run the test:
notice that there was no complaint about:
inside
./source/index.js
The text was updated successfully, but these errors were encountered: