feat(ts): can change tsconfig by env (#136)
This commit is contained in:
parent
b93f48f429
commit
fe73faf458
11
README.md
11
README.md
@ -57,7 +57,16 @@ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?it
|
|||||||
|
|
||||||
### TypeScript Aware Rules
|
### TypeScript Aware Rules
|
||||||
|
|
||||||
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. Refer to [this file](https://github.com/antfu/eslint-config/blob/main/packages/typescript/index.js#L17).
|
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// .eslintrc.js
|
||||||
|
process.env.ESLINT_TSCONFIG = 'tsconfig.json'
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
extends: '@antfu'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Extended Reading
|
## Extended Reading
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ const fs = require('fs')
|
|||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
const basic = require('@antfu/eslint-config-basic')
|
const basic = require('@antfu/eslint-config-basic')
|
||||||
|
|
||||||
|
const tsconfig = process.env.ESLINT_TSCONFIG || 'tsconfig.eslint.json'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: [
|
extends: [
|
||||||
'@antfu/eslint-config-basic',
|
'@antfu/eslint-config-basic',
|
||||||
@ -14,12 +16,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
overrides: basic.overrides.concat(
|
overrides: basic.overrides.concat(
|
||||||
!fs.existsSync(join(process.cwd(), 'tsconfig.eslint.json'))
|
!fs.existsSync(join(process.cwd(), tsconfig))
|
||||||
? []
|
? []
|
||||||
: [{
|
: [{
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
tsconfigRootDir: process.cwd(),
|
tsconfigRootDir: process.cwd(),
|
||||||
project: ['tsconfig.eslint.json'],
|
project: [tsconfig],
|
||||||
},
|
},
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
excludedFiles: ['**/*.md/*.*'],
|
excludedFiles: ['**/*.md/*.*'],
|
||||||
|
Loading…
Reference in New Issue
Block a user