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
Should Ignore js files for type awared rules #375
Comments
I guess it's mostly trying to say you are missing I do agree config should not chech ts rules on js files by default unless you have allowJs on, so you don't have to make |
I don't think this is
What's you mean? Whether I include that js file or not, it gives an error, like I said in the post. |
The problem is there is no easy way to not typecheck JS files import antfu from '@antfu/eslint-config'
export default antfu({
typescript: {
tsconfigPath: './tsconfig.json',
},
// overrides: {
// javascript: {
// 'ts/no-unsafe-argument': 'off', // won't work
// },
// },
}, {
files: ['**/*.js'],
rules: {
'ts/no-unsafe-argument': 'off',
'ts/no-unsafe-assignment': 'off',
'ts/no-unsafe-call': 'off',
'ts/no-unsafe-member-access': 'off',
'ts/no-unsafe-return': 'off',
},
}) will error less but will still require JS in your tsconfig @antfu please consider adding some easy way to exclude out-of-tsconfig files from type-aware rules export async function typescript(
options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions = {},
): Promise<FlatConfigItem[]> {
const {
componentExts = [],
overrides = {},
parserOptions = {},
+ excludes = [], // e.g. `['**/*.js']` or `['./*.js']` or `['./scripts/**/*']` to exclude files that are not in tsconfig
} = options
const files = options.files ?? [
- GLOB_SRC,
+ options.typecheckJs ? GLOB_SRC : GLOB_TS, // some way to disable type-aware-rules for JS
+ // as they are often configs/scrips outside of the project.
+ // Currently you *have* to add eslint.config.js into tsconfig or it gonna bark
...componentExts.map(ext => `**/*.${ext}`),
] |
Describe the bug
When I assign a tsconfig path to
typescript
option. It told me I should include the js file to tsconfig.jsonHowever, after I include the js files in tsconfig. It told me there has some types is unsafe, like this
Actually I don't really want to check the js files' type. I'm not sure if this is expected behavior or a bug.
Happy to contribute if it is a bug :)
Reproduction
https://github.com/mutoe-archive/antfu-eslint-config-type-aware-in-js-issue
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: