Skip to content

Commit

Permalink
Improve TypeScript config (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
JstnMcBrd authored Aug 12, 2024
1 parent 4265b16 commit 418f066
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
}
274 changes: 132 additions & 142 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@
},
"dependencies": {
"@eslint/js": "^8.57.0",
"@stylistic/eslint-plugin": "^2.2.1",
"eslint-plugin-react": "^7.34.1",
"@stylistic/eslint-plugin": "^2.3.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"globals": "^15.6.0",
"typescript-eslint": "^7.13.1"
"globals": "^15.9.0",
"typescript-eslint": "^7.18.0"
},
"devDependencies": {
"@types/eslint": "^8.56.11",
"@types/eslint__js": "^8.42.3",
"eslint": "^8.57.0",
"typescript": "^5.4.5"
"typescript": "^5.5.4"
},
"peerDependencies": {
"eslint": ">=8.21.0 <9.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/@types/eslint-plugin-react-hooks.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This is only a type-shim and is not meant to be a perfect representation
// https://github.com/facebook/react/issues/30119

declare module 'eslint-plugin-react-hooks' {
import type { ESLint } from 'eslint';
Expand Down
1 change: 1 addition & 0 deletions src/@types/eslint-plugin-react.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This is only a type-shim and is not meant to be a perfect representation
// https://github.com/jsx-eslint/eslint-plugin-react/issues/3776

declare module 'eslint-plugin-react' {
import type { ESLint } from 'eslint';
Expand Down
5 changes: 2 additions & 3 deletions src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import reactHooksPlugin from 'eslint-plugin-react-hooks';
import type { Linter } from 'eslint';
import globals from 'globals';

import { javascript } from './javascript.js';

/** @returns ESLint configuration for React. */
export function react(): Linter.FlatConfig[] {
return [
// Make sure to give browser globals to all other project files, not just JSX files
{
files: javascript()[0]?.files,
// FIXME Reused code from src/javascript.ts - abstract out
files: ['**/*.{m,c,}{js,ts}{x,}'],
languageOptions: {
globals: globals.browser,
},
Expand Down
2 changes: 1 addition & 1 deletion src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function typescript(): Linter.FlatConfig[] {
...tsESLint.configs.stylisticTypeChecked[2]?.rules,

// Overrides
'no-shadow': 0, // handled by TypeScript
'no-shadow': 0, // TODO Replace with @typescript-eslint/no-shadow (breaking change)
},
},
];
Expand Down
8 changes: 5 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"outDir": "dist",
"declaration": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"isolatedDeclarations": true,

// For the globals package
"resolveJsonModule": true,
Expand Down

0 comments on commit 418f066

Please sign in to comment.