🐞 Bug report
Linting raw JS files in a project that uses the exported typescript config fails with the following message:
Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.
Parser: typescript-eslint/parser
Occurred while linting /home/lotus/.local/share/git_worktrees/3a52ce780950d4d969792a2559cd519d7ee8c727/file.js
This happens because the recommendedTypeChecked config from typescript-eslint is generated without a filter for only TS files. This requires loading the type information for the project, which might not be relevant or even valid. Ideally, TS-only rules should be applied only to TS/TSX files.
Steps to reproduce
- Create a project using the
configs.typescript rules exported:
import {defineConfig} from 'eslint/config';
import {configs} from '@croct/eslint-plugin';
export default defineConfig(configs.typescript)
- Create a pure JS file (
.[cm]?js)
- Run
eslint file.js
Expected behavior
JS files should be validated with the javascript config even on projects using typescript.
Additional context
A workaround:
import { defineConfig } from 'eslint/config';
import { configs } from '@croct/eslint-plugin';
export default defineConfig(
configs.javascript.map(
config => ({
files: ['**/*.{js,mjs,cjs}'],
...config,
}),
),
configs.typescript.map(
config => ({
files: ['**/*.{ts,mts,cts}'],
...config,
}),
),
);
🐞 Bug report
Linting raw JS files in a project that uses the exported typescript config fails with the following message:
This happens because the
recommendedTypeCheckedconfig fromtypescript-eslintis generated without a filter for only TS files. This requires loading the type information for the project, which might not be relevant or even valid. Ideally, TS-only rules should be applied only to TS/TSX files.Steps to reproduce
configs.typescriptrules exported:.[cm]?js)eslint file.jsExpected behavior
JS files should be validated with the
javascriptconfig even on projects using typescript.Additional context
A workaround: