Skip to content

Commit

Permalink
chore(eslint): add eslint-typegen (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrbrown committed Sep 9, 2024
1 parent 07d934e commit 2459d41
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*

# eslint-typegen (https://github.com/antfu/eslint-typegen)
eslint-typegen.d.ts
148 changes: 74 additions & 74 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,88 @@ import eslint from '@eslint/js'
import type {Linter} from 'eslint'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import typegen from 'eslint-typegen'

/// <reference types="@eslint-types/import" />
/// <reference types="@eslint-types/typescript-eslint" />

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
ignores: ['**/__tests__', '**/dist', '**/lib', '**/node_modules'],
},

{
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.es2021,
...globals.node,
},
export default typegen(
tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
ignores: ['**/__tests__', '**/dist', '**/lib', '**/node_modules'],
},

parserOptions: {
{
languageOptions: {
ecmaVersion: 2022,
projectService: true,
globals: {
...globals.es2021,
...globals.node,
},

parserOptions: {
ecmaVersion: 2022,
projectService: true,
sourceType: 'module',
},
sourceType: 'module',
},
sourceType: 'module',
},

rules: {
'i18n-text/no-en': 'off',
'eslint-comments/no-use': 'off',
'import/no-namespace': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
rules: {
'i18n-text/no-en': 'off',
'eslint-comments/no-use': 'off',
'import/no-namespace': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',

'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],

'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
camelcase: 'off',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
camelcase: 'off',
'@typescript-eslint/consistent-type-assertions': 'error',

'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],

// Moved to https://eslint.style - https://github.com/typescript-eslint/typescript-eslint/issues/8074
// '@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
semi: 'off',
// Moved to https://eslint.style - https://github.com/typescript-eslint/typescript-eslint/issues/8074
// '@typescript-eslint/semi': ['error', 'never'],
// '@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error',
// Moved to https://eslint.style - https://github.com/typescript-eslint/typescript-eslint/issues/8074
// '@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
semi: 'off',
// Moved to https://eslint.style - https://github.com/typescript-eslint/typescript-eslint/issues/8074
// '@typescript-eslint/semi': ['error', 'never'],
// '@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error',
},
},
},
) as Linter.Config
) as Linter.Config[],
)
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
"devDependencies": {
"@bfra.me/prettier-config": "0.5.0",
"@bfra.me/tsconfig": "0.6.0",
"@eslint-types/import": "2.29.1",
"@eslint-types/typescript-eslint": "7.5.0",
"@eslint/js": "9.10.0",
"@semantic-release/git": "10.0.1",
"@types/eslint__js": "8.42.3",
"@types/node": "20.16.0",
"@vercel/ncc": "0.38.1",
"conventional-changelog-conventionalcommits": "8.0.0",
"eslint": "9.10.0",
"eslint-typegen": "0.3.2",
"globals": "15.9.0",
"jiti": "1.21.6",
"js-yaml": "4.1.0",
Expand Down
58 changes: 42 additions & 16 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"noEmit": true,
"target": "ESNext"
},
"exclude": ["dist", "node_modules", "**/*.test.ts"],
"include": ["src", "eslint.config.ts"]
"exclude": ["dist", "node_modules"],
"include": ["**/*.ts"]
}

0 comments on commit 2459d41

Please sign in to comment.