croct-tech / croct-tech/coding-standard-js
Typescript-only rules are being checked against pure JS files
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
🐞 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.typescriptrules 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,
}),
),
);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the exported configs.typescript and configs.javascript definitions in the repository, then reproduce the report with ESLint on a pure .js or .ts file. Ensure JavaScript files use the javascript config while TypeScript-only rules apply only to TypeScript files, and verify the behavior with the reported reproduction steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100