-
Notifications
You must be signed in to change notification settings - Fork 50
Upgrade to type-checked ESLint rules (demonstrates scope of PR 465) #1159
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,32 +5,46 @@ import importPlugin from "eslint-plugin-import"; | |||||||||||||
const opts = tseslint.config( | ||||||||||||||
eslint.configs.recommended, | ||||||||||||||
// ...tseslint.configs.recommended, | ||||||||||||||
...tseslint.configs.strict, | ||||||||||||||
...tseslint.configs.stylistic, | ||||||||||||||
// ...tseslint.configs.strict, | ||||||||||||||
// ...tseslint.configs.stylistic, | ||||||||||||||
...tseslint.configs.strictTypeChecked, | ||||||||||||||
...tseslint.configs.stylisticTypeChecked, | ||||||||||||||
...tseslint.configs.recommendedTypeChecked, | ||||||||||||||
{ | ||||||||||||||
languageOptions: { | ||||||||||||||
globals: { | ||||||||||||||
queueMicrotask: "readonly", | ||||||||||||||
parserOptions: { | ||||||||||||||
sourceType: "module", | ||||||||||||||
project: "./tsconfig.json", | ||||||||||||||
// projectService: true, | ||||||||||||||
tsconfigRootDir: import.meta.dirname, | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
{ | ||||||||||||||
ignores: [ | ||||||||||||||
"babel.config.cjs", | ||||||||||||||
"prettier.config.js", | ||||||||||||||
"jest.config.js", | ||||||||||||||
"setup.*.js", | ||||||||||||||
"to-esm.js", | ||||||||||||||
"vitest.*.ts", | ||||||||||||||
"**/.esm-cache/**", | ||||||||||||||
"**/dist/", | ||||||||||||||
"dist/**", | ||||||||||||||
"**/pubdir/", | ||||||||||||||
"**/node_modules/", | ||||||||||||||
"**/scripts/", | ||||||||||||||
"**/examples/", | ||||||||||||||
"scripts/", | ||||||||||||||
"coverage/", | ||||||||||||||
"smoke/react/", | ||||||||||||||
"src/missingTypes/lib.deno.d.ts", | ||||||||||||||
"**/.cache/**", | ||||||||||||||
"**/.esm-cache/**", | ||||||||||||||
"**/.wrangler/**", | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
{ | ||||||||||||||
files: ["**/*.js", "*.mjs"], | ||||||||||||||
extends: [tseslint.configs.disableTypeChecked], | ||||||||||||||
}, | ||||||||||||||
Comment on lines
+45
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 🧩 Analysis chainJS override misses nested .mjs and all .cjs files. This leaves type‑checked rules active in those files. Expand globs. Apply this diff: - files: ["**/*.js", "*.mjs"],
+ files: ["**/*.js", "**/*.mjs", "**/*.cjs"], Quick check: 🏁 Script executed: #!/bin/bash
echo "Any nested .mjs/.cjs files not matched by '*.mjs'?"; fd -t f -e mjs -e cjs | sed '1,1d' || true Length of output: 113 Expand override globs to include nested .mjs and all .cjs files "*.mjs" only matches top-level .mjs and misses nested .mjs/.cjs — fd lists smoke/npm/patch-package.json.mjs and smoke/react/eslint.config.mjs. File: eslint.config.mjs (lines 45-47) - files: ["**/*.js", "*.mjs"],
+ files: ["**/*.js", "**/*.mjs", "**/*.cjs"], 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
{ | ||||||||||||||
plugins: { | ||||||||||||||
import: importPlugin, | ||||||||||||||
|
@@ -53,6 +67,12 @@ const opts = tseslint.config( | |||||||||||||
"no-restricted-globals": ["error", "URL", "TextDecoder", "TextEncoder"], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
{ | ||||||||||||||
files: ["**/*.ts", "**/*.tsx"], | ||||||||||||||
rules: { | ||||||||||||||
"@typescript-eslint/prefer-readonly": "error", | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
export default opts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Ensure all linted TS files are covered by project config
The new type‑checked config sets
parserOptions.project: "./tsconfig.json"
, but that tsconfig only includescore
,cloud
,cli
,dashboard
, andtests
. Directories likeuse-fireproof/
andsmoke/npm/
still contain TypeScript files and are not ignored. Runningpnpm lint
against those files will now fail withParsing error: File ... is not included in the project
before any of the intended rule diagnostics are emitted. Consider adding a dedicatedtsconfig.eslint.json
that references every package or explicitly ignoring the out-of-project folders so lint can complete.Useful? React with 👍 / 👎.