Skip to content

Commit

Permalink
feat(ts): add TypeScript Aware Rules from @typescript-eslint/recommen… (
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Dec 12, 2022
1 parent 4d38bd0 commit b93f48f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
@@ -1,6 +1,7 @@
// Ported from https://github.com/gajus/eslint-plugin-canonical/blob/master/src/rules/preferInlineTypeImport.js
// 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'

export const RULE_NAME = 'prefer-inline-type-import'
Expand Down Expand Up @@ -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 typeIdentifier = sourceCode.getTokenAfter(importKeyword)
Expand Down
14 changes: 14 additions & 0 deletions packages/typescript/index.js
Expand Up @@ -24,6 +24,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
excludedFiles: ['**/*.md/*.*'],
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: {
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': 'error',
Expand All @@ -34,6 +35,19 @@ module.exports = {
'no-void': ['error', { allowAsStatement: 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',
},
}],
),
Expand Down

0 comments on commit b93f48f

Please sign in to comment.