Skip to content

Commit

Permalink
[ts] basic rules structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhyde committed Jul 3, 2024
1 parent 24daba1 commit 7f3bea9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 63 deletions.
63 changes: 2 additions & 61 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,62 +1,3 @@
import love from 'eslint-config-love'
import jsdoc from 'eslint-plugin-jsdoc'
import vitest from 'eslint-plugin-vitest'
import tb from './build/index.js'

export default [
// ignores key should be used first and without any other keys in the configuration object
{
ignores: ['build', 'docs']
},
jsdoc.configs['flat/recommended-typescript-error'],
love,
// general
{
rules: {
'import/no-default-export': 'error',
// don't work without typescript import specifier support
'import/no-unresolved': 'off',
'jsdoc/check-param-names': ['error', { checkDestructured: false }],
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/require-jsdoc': ['error', { require: { FunctionExpression: true, ArrowFunctionExpression: true } }],
'jsdoc/require-param': ['error', { checkDestructured: false }],
'jsdoc/require-returns': 'off',
'jsdoc/require-throws': 'error',
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }]
}
},
// typescript
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/strict-boolean-expressions': ['error', { allowNullableObject: true }],
'@typescript-eslint/space-before-function-paren': 'off',
'n/prefer-node-protocol': 'error'
}
},
// vitest
{
files: ['**/*.test.ts'],
plugins: {
vitest
},
settings: {
vitest: {
typecheck: true
}
},
languageOptions: {
globals: {
...vitest.environments.env.globals
}
},
rules: {
...vitest.configs.all.rules,
'vitest/max-nested-describe': ['error', { max: 3 }],
'vitest/no-hooks': ['error', { allow: ['afterEach'] }],
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }]
}
}
]
export default [tb.configs.all]
11 changes: 11 additions & 0 deletions source/configs/all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import js from '@eslint/js'
import type { Linter } from 'eslint'
import ts from 'typescript-eslint'

const all: Linter.FlatConfig = Object.freeze({
name: '2bad/all',
...js.configs.all,
...ts.configs.all
})

export default all
11 changes: 11 additions & 0 deletions source/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import js from '@eslint/js'
import type { Linter } from 'eslint'
import ts from 'typescript-eslint'

const recommended: Linter.FlatConfig = Object.freeze({
name: '2bad/recommended',
...js.configs.recommended,
...ts.configs.recommended
})

export default recommended
11 changes: 11 additions & 0 deletions source/configs/strict.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import js from '@eslint/js'
import type { Linter } from 'eslint'
import ts from 'typescript-eslint'

const strict: Linter.FlatConfig = Object.freeze({
name: '2bad/strict',
...js.configs.all,
...ts.configs.strict
})

export default strict
15 changes: 13 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import { go, where } from '~/quotes/parts.ts'
import type { ESLint } from 'eslint'
import all from './configs/all.ts'
import recommended from './configs/recommended.ts'
import strict from './configs/strict.ts'

export const quote = `${go} ${where}`
const plugin: ESLint.Plugin = {
configs: {
recommended,
strict,
all
}
}

export default plugin

0 comments on commit 7f3bea9

Please sign in to comment.