feat(ts): add TypeScript Aware Rules from @typescript-eslint/recommen… (#135)
This commit is contained in:
parent
4d38bd0293
commit
b93f48f429
@ -1,6 +1,7 @@
|
|||||||
// Ported from https://github.com/gajus/eslint-plugin-canonical/blob/master/src/rules/preferInlineTypeImport.js
|
// Ported from https://github.com/gajus/eslint-plugin-canonical/blob/master/src/rules/preferInlineTypeImport.js
|
||||||
// by Gajus Kuizinas https://github.com/gajus
|
// by Gajus Kuizinas https://github.com/gajus
|
||||||
|
import type { TSESTree } from '@typescript-eslint/utils'
|
||||||
|
import type { RuleFixer, SourceCode } from '@typescript-eslint/utils/dist/ts-eslint'
|
||||||
import { createEslintRule } from '../utils'
|
import { createEslintRule } from '../utils'
|
||||||
|
|
||||||
export const RULE_NAME = 'prefer-inline-type-import'
|
export const RULE_NAME = 'prefer-inline-type-import'
|
||||||
@ -47,7 +48,7 @@ export default createEslintRule<Options, MessageIds>({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
function *removeTypeSpecifier(fixer, sourceCode, node) {
|
function * removeTypeSpecifier(fixer: RuleFixer, sourceCode: Readonly<SourceCode>, node: TSESTree.ImportDeclaration) {
|
||||||
const importKeyword = sourceCode.getFirstToken(node)
|
const importKeyword = sourceCode.getFirstToken(node)
|
||||||
|
|
||||||
const typeIdentifier = sourceCode.getTokenAfter(importKeyword)
|
const typeIdentifier = sourceCode.getTokenAfter(importKeyword)
|
||||||
|
@ -24,6 +24,7 @@ module.exports = {
|
|||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
excludedFiles: ['**/*.md/*.*'],
|
excludedFiles: ['**/*.md/*.*'],
|
||||||
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
|
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
|
||||||
|
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
|
||||||
rules: {
|
rules: {
|
||||||
'no-throw-literal': 'off',
|
'no-throw-literal': 'off',
|
||||||
'@typescript-eslint/no-throw-literal': 'error',
|
'@typescript-eslint/no-throw-literal': 'error',
|
||||||
@ -34,6 +35,19 @@ module.exports = {
|
|||||||
'no-void': ['error', { allowAsStatement: true }],
|
'no-void': ['error', { allowAsStatement: true }],
|
||||||
'@typescript-eslint/no-floating-promises': 'error',
|
'@typescript-eslint/no-floating-promises': 'error',
|
||||||
'@typescript-eslint/no-misused-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',
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user