Skip to content

Commit

Permalink
feat(disable-type-aware): Using process.env.DISABLE_TYPE_AWARE to let…
Browse files Browse the repository at this point in the history
… user disable type-aware linting (#123)
  • Loading branch information
yuaanlin authored Feb 24, 2022
1 parent 8279618 commit c67b52d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as path from 'path';
import * as fs from 'fs';
import tsEslintConfig from './tsEslintConfig';

const isTypeAwareEnabled = process.env.DISABLE_TYPE_AWARE === undefined;

const parserOptions = {
ecmaFeatures: {
jsx: true,
Expand All @@ -14,7 +16,7 @@ const parserOptions = {
],
},
requireConfigFile: false,
project: './tsconfig.json',
project: isTypeAwareEnabled ? './tsconfig.json' : undefined,
};

const isJsMoreTs = async (path = 'src') => {
Expand Down
8 changes: 5 additions & 3 deletions src/tsEslintConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const isTypeAwareEnabled = process.env.DISABLE_TYPE_AWARE === undefined;

export default {
'no-undef': 0,
'@typescript-eslint/adjacent-overload-signatures': 0,
Expand All @@ -19,7 +21,7 @@ export default {
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 0,
'dot-notation': 'off',
'@typescript-eslint/dot-notation': 1,
'@typescript-eslint/dot-notation': isTypeAwareEnabled ? 1 : 0,
'@typescript-eslint/explicit-function-return-type': 0,
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': 0,
Expand Down Expand Up @@ -79,7 +81,7 @@ export default {
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-this-alias': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-throw-literal': isTypeAwareEnabled ? 2 : 0,
'@typescript-eslint/no-type-alias': 0,
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 0,
'@typescript-eslint/no-unnecessary-condition': 0,
Expand Down Expand Up @@ -130,7 +132,7 @@ export default {
'space-infix-ops': 'off',
'@typescript-eslint/space-infix-ops': 0,
'@typescript-eslint/strict-boolean-expressions': 0,
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/switch-exhaustiveness-check': isTypeAwareEnabled ? 2 : 0,
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/typedef': 'error',
Expand Down

0 comments on commit c67b52d

Please sign in to comment.