Comments (6)
Worth an update of docs and config everywhere? typescript-eslint/typescript-eslint#3824 (comment)
from eslint-config-xo-typescript.
This enables XO’s config on TS files as well:
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"xo",
"xo-typescript"
],
I don't see anything special about it here: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/eslint-recommended.ts
from eslint-config-xo-typescript.
That's weird. I don't see anything regarding extensions in the typescript-eslint
config.
from eslint-config-xo-typescript.
Weird indeed. Also confirmed with this repro:
npm init -y
npm install eslint eslint-config-xo eslint-config-xo-typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
echo '// @ts-ignore' > index.ts
echo '{}' > tsconfig.json
echo '{"extends":["xo","xo-typescript"]}' > .eslintrc
npx eslint .
Then this config produces:
Oops! Something went wrong! :(
ESLint: 7.30.0
No files matching the pattern "." were found.
Please check for typing mistakes in the pattern.
Add that the plugin and run again:
echo '{"extends":["plugin:@typescript-eslint/recommended","xo","xo-typescript"]}' > .eslintrc
npx eslint .
./index.ts
1:1 error Use "@ts-expect-error" to ensure an error is actually being suppressed @typescript-eslint/prefer-ts-expect-error
1:1 error Do not use "@ts-ignore" because it alters compilation errors @typescript-eslint/ban-ts-comment
✖ 2 problems (2 errors, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Then remove XO’s config:
echo '{"extends":["plugin:@typescript-eslint/recommended"]}' > .eslintrc
npx eslint .
./index.ts
1:1 error Do not use "@ts-ignore" because it alters compilation errors @typescript-eslint/ban-ts-comment
✖ 1 problem (1 error, 0 warnings)
from eslint-config-xo-typescript.
Sure
from eslint-config-xo-typescript.
I think I know why, and I think this config should follow suit:
The rules are defined in an override for .ts files, specifying those extensions, whereas eslint-config-xo-typescript
just loads all rules in the top level.
If the change isn't made here, I think the user should set up the config as:
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": [
"xo",
],
overrides: [{
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
"extends": [
"xo-typescript"
]
}]
}
}
Note that this means users will also need to specify TypeScript-related rule changes in an override, if they have any. For example this won't work:
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": [
"xo",
],
+ "rules": {
+ "@typescript-eslint/no-unsafe-assignment": "warn" // Must be in overrides too
+ },
overrides: [{
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
"extends": [
"xo-typescript"
],
}]
}
}
from eslint-config-xo-typescript.
Related Issues (20)
- unicorn/prefer-json-parse-buffer is incompatible with TypeScript
- @typescript-eslint/naming-convention should ignore all exotic keys HOT 1
- Enable `@typescript-eslint/consistent-type-definitions` rule HOT 2
- Use `eslint-import-resolver-typescript` instead of `eslint-import-resolver-node`? HOT 1
- should `@typescript-eslint/parser` be listed in peer dependencies? HOT 1
- Drop `@typescript-eslint/consistent-type-definitions` rule HOT 4
- Update rule to prefer `import {type X}` over `import type {X}` HOT 2
- Configuration for rule "@typescript-eslint/consistent-type-imports" is invalid: Value {"fixStyle":"inline-type-imports"} should NOT have additional properties. HOT 1
- Invalid configuration for `@typescript-eslint/member-ordering`
- Don't disable unicorn/no-null?
- Consider enabling `strict-boolean-expressions`? HOT 1
- Change `parserOptions.jsx` to `parserOptions.ecmaFeatures.jsx`?
- Upgrade `@typescript-eslint/eslint-plugin` dependency to `5.45.0` minimum. HOT 1
- Invalid configuration for `@typescript-eslint/restirct-plus-operands`
- Invalid configuration for `@typescript-eslint/no-restricted-imports`
- Off `import/named`
- Disable the `import/no-duplicates` rule HOT 1
- Consider disabling `default-case` because of `@typescript-eslint/switch-exhaustiveness-check`
- Conflicts with @typescript-eslint libraries
- `switch-exhaustiveness-check` config mismatch? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-config-xo-typescript.