Skip to content

Commit

Permalink
fix(ts): fixes tsconfig overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
barisbora committed May 17, 2023
1 parent 0dd4f2b commit 1f1c753
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
44 changes: 44 additions & 0 deletions packages/eslint-config-ts/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const fs = require('node:fs');
const { join } = require('node:path');
const basic = require('@owowagency/eslint-config-basic');

const tsconfig = process.env.ESLINT_TSCONFIG || 'tsconfig.eslint.json';

module.exports = {
extends: [
'@owowagency/eslint-config-basic',
Expand All @@ -9,6 +15,44 @@ module.exports = {
node: { extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts'] },
},
},
overrides: basic.overrides.concat(
!fs.existsSync(join(process.cwd(), tsconfig))
? []
: [
{
parserOptions: {
tsconfigRootDir: process.cwd(),
project: [tsconfig],
},
parser: '@typescript-eslint/parser',
excludedFiles: ['**/*.md/*.*'],
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
rules: {
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'dot-notation': 'off',
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/unbound-method': 'error',
},
},
],
),
rules: {
'import/named': 'off',

Expand Down
12 changes: 1 addition & 11 deletions packages/eslint-config-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@
},
"peerDependencies": {
"eslint": ">=7.4.0",
"typescript": ">=4.3.4"
},
"peerDependenciesMeta": {
"eslint": {
"optional": false,
"autoInstall": true
},
"typescript": {
"optional": false,
"autoInstall": true
}
"typescript": ">=3.9"
},
"dependencies": {
"@owowagency/eslint-config-basic": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1f1c753

Please sign in to comment.