-
Notifications
You must be signed in to change notification settings - Fork 235
feat(eslint-config): enable linting with type information #1098
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
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@hono/eslint-config': major | ||
--- | ||
|
||
Includes `typescript-eslint` presets for typed linting | ||
|
||
- [`strict-type-checked`](https://typescript-eslint.io/users/configs#strict-type-checked) | ||
- [`stylistic-type-checked`](https://typescript-eslint.io/users/configs#stylistic-type-checked) | ||
|
||
See [Linting with Type Information](https://typescript-eslint.io/getting-started/typed-linting) for more information |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,62 @@ | ||
import baseConfig from '@hono/eslint-config' | ||
import { defineConfig, globalIgnores } from 'eslint/config' | ||
|
||
export default defineConfig(globalIgnores(['.yarn', '**/dist']), { | ||
export default defineConfig(globalIgnores(['.yarn', '**/coverage', '**/dist']), { | ||
extends: baseConfig, | ||
|
||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
Comment on lines
+7
to
+12
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. This tells the |
||
|
||
linterOptions: { | ||
reportUnusedDisableDirectives: 'error', | ||
reportUnusedInlineConfigs: 'error', | ||
}, | ||
Comment on lines
+14
to
+17
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. Additional linter options
|
||
|
||
rules: { | ||
'@typescript-eslint/array-type': 'off', | ||
'@typescript-eslint/await-thenable': 'off', | ||
'@typescript-eslint/consistent-indexed-object-style': 'off', | ||
'@typescript-eslint/consistent-type-definitions': 'off', | ||
'@typescript-eslint/dot-notation': 'off', | ||
'@typescript-eslint/no-base-to-string': 'off', | ||
'@typescript-eslint/no-confusing-void-expression': 'off', | ||
'@typescript-eslint/no-deprecated': 'off', | ||
'@typescript-eslint/no-duplicate-type-constituents': 'off', | ||
'@typescript-eslint/no-dynamic-delete': 'off', | ||
'@typescript-eslint/no-floating-promises': 'off', | ||
'@typescript-eslint/no-invalid-void-type': 'off', | ||
'@typescript-eslint/no-misused-promises': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-redundant-type-constituents': 'off', | ||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'@typescript-eslint/no-unnecessary-template-expression': 'off', | ||
'@typescript-eslint/no-unnecessary-type-arguments': 'off', | ||
'@typescript-eslint/no-unnecessary-type-assertion': 'off', | ||
'@typescript-eslint/no-unnecessary-type-parameters': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-enum-comparison': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
'@typescript-eslint/no-useless-constructor': 'off', | ||
'@typescript-eslint/non-nullable-type-assertion-style': 'off', | ||
'@typescript-eslint/only-throw-error': 'off', | ||
'@typescript-eslint/prefer-function-type': 'off', | ||
'@typescript-eslint/prefer-includes': 'off', | ||
'@typescript-eslint/prefer-nullish-coalescing': 'off', | ||
'@typescript-eslint/prefer-optional-chain': 'off', | ||
'@typescript-eslint/prefer-regexp-exec': 'off', | ||
'@typescript-eslint/prefer-return-this-type': 'off', | ||
'@typescript-eslint/require-await': 'off', | ||
'@typescript-eslint/restrict-plus-operands': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/unbound-method': 'off', | ||
'@typescript-eslint/unified-signatures': 'off', | ||
}, | ||
Comment on lines
+19
to
+61
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. I've initially disabled all the new rules to keep this PR small I'd be happy to revisit each rule individually and decide if it's worth enabling or not. If a new rule is problematic, it can always be disabled in the shared eslint config My personal preference is to have less configuration, and rely on tooling to make these decisions for me. But I understand that doesn't fit with how everyone works 😅 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.
I like this approach. Fixing lint errors is troublesome, and the diffs will be huge. We don't have to do it. |
||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ import tseslint from 'typescript-eslint' | |
export default [ | ||
js.configs.recommended, | ||
nodePlugin.configs['flat/recommended'], | ||
...tseslint.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
...tseslint.configs.stylisticTypeChecked, | ||
Comment on lines
+10
to
+11
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. There's a few shared configs to choose from. Their suggestion is to enabling |
||
{ | ||
plugins: { | ||
'@typescript-eslint': tseslint.plugin, | ||
|
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. Includes |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc/packages/graphql-server", | ||
"types": ["bun"] | ||
}, | ||
"exclude": ["src/**/*.test.ts"], | ||
"include": ["bun_test", "vitest.config.ts"], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.build.json" | ||
} | ||
] | ||
} |
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.
Yes. This change includes breaking change, so this is a
major
version up.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.
Feel free to ping me if you need help upgrading other projects that use
@hono/eslint-config