/ login-server / eslint.config.mjs
eslint.config.mjs
  1  import { defineConfig, globalIgnores } from 'eslint/config'
  2  import typescriptEslint from '@typescript-eslint/eslint-plugin'
  3  import tsParser from '@typescript-eslint/parser'
  4  import path from 'node:path'
  5  import { fileURLToPath } from 'node:url'
  6  import js from '@eslint/js'
  7  import { FlatCompat } from '@eslint/eslintrc'
  8  import stylistic from '@stylistic/eslint-plugin'
  9  import unusedImports from 'eslint-plugin-unused-imports'
 10  
 11  const __filename = fileURLToPath( import.meta.url )
 12  const __dirname = path.dirname( __filename )
 13  const compat = new FlatCompat( {
 14      baseDirectory: __dirname,
 15      recommendedConfig: js.configs.recommended,
 16      allConfig: js.configs.all
 17  } )
 18  
 19  export default defineConfig( [ globalIgnores( [ 'dist/**/*.ts', 'dist/**/*.js' ] ), {
 20      extends: compat.extends( 'eslint:recommended', 'plugin:@typescript-eslint/recommended' ),
 21  
 22      plugins: {
 23          '@typescript-eslint': typescriptEslint,
 24          '@stylistic': stylistic,
 25          'unused-imports': unusedImports
 26      },
 27  
 28      languageOptions: {
 29          parser: tsParser,
 30          ecmaVersion: 5,
 31          sourceType: 'script',
 32  
 33          parserOptions: {
 34              project: [ './tsconfig.json' ],
 35          },
 36      },
 37  
 38      rules: {
 39          '@typescript-eslint/no-unused-vars': 'off',
 40          '@typescript-eslint/no-var-requires': 'off',
 41          '@typescript-eslint/no-explicit-any': 'off',
 42          'prefer-const': 'off',
 43          '@typescript-eslint/no-this-alias': 'off',
 44          '@typescript-eslint/ban-types': 'off',
 45          '@typescript-eslint/no-empty-function': 'off',
 46          'no-constant-condition': 'warn',
 47          '@typescript-eslint/no-inferrable-types': 'off',
 48          'no-case-declarations': 'off',
 49          'no-fallthrough': 'off',
 50          '@typescript-eslint/no-empty-interface': 'off',
 51          '@typescript-eslint/ban-ts-comment': 'warn',
 52  
 53          '@typescript-eslint/array-type': [ 'error', {
 54              default: 'generic',
 55          } ],
 56  
 57          'arrow-spacing': [ 'error', {
 58              before: true,
 59              after: true,
 60          } ],
 61  
 62          'array-bracket-spacing': [ 'error', 'always', {
 63              arraysInArrays: true,
 64              objectsInArrays: true,
 65              singleValue: true,
 66          } ],
 67  
 68          'brace-style': [ 'error', '1tbs' ],
 69          'space-in-parens': [ 'error', 'always' ],
 70          'comma-style': [ 'error', 'last' ],
 71          'computed-property-spacing': [ 'error', 'always' ],
 72  
 73          'key-spacing': [ 'error', {
 74              beforeColon: false,
 75              afterColon: true,
 76              mode: 'strict',
 77          } ],
 78  
 79          'max-statements-per-line': [ 'error', {
 80              max: 1,
 81          } ],
 82  
 83          quotes: [ 'error', 'single' ],
 84  
 85          'keyword-spacing': [ 'error', {
 86              before: true,
 87              after: true,
 88          } ],
 89  
 90          'no-mixed-spaces-and-tabs': 'error',
 91          'no-tabs': 'error',
 92          'no-whitespace-before-property': 'error',
 93          'no-extra-semi': 'error',
 94  
 95          'no-confusing-arrow': [ 'error', {
 96              allowParens: false,
 97              onlyOneSimpleParam: false,
 98          } ],
 99  
100          'no-else-return': [ 'error', {
101              allowElseIf: true,
102          } ],
103  
104          semi: [ 'error', 'never' ],
105          'space-before-blocks': [ 'error', 'always' ],
106  
107          'switch-colon-spacing': [ 'error', {
108              after: true,
109              before: false,
110          } ],
111  
112          'no-eval': 'error',
113          'no-extra-boolean-cast': 'error',
114          'no-implied-eval': 'error',
115          'no-invalid-this': 'error',
116          'no-lone-blocks': 'error',
117          'no-multi-assign': 'error',
118          'no-redeclare': 'off',
119          'no-return-await': 'error',
120          'no-var': 'error',
121          'no-with': 'error',
122          'no-multi-spaces': 'error',
123          'no-trailing-spaces': 'error',
124          '@typescript-eslint/explicit-function-return-type': 'off',
125          '@typescript-eslint/no-confusing-non-null-assertion': 'error',
126          '@typescript-eslint/no-confusing-void-expression': 'off',
127          '@typescript-eslint/no-dynamic-delete': 'off',
128          '@typescript-eslint/no-extra-non-null-assertion': 'error',
129          '@typescript-eslint/no-floating-promises': 'warn',
130          '@typescript-eslint/no-for-in-array': 'error',
131          '@typescript-eslint/no-meaningless-void-operator': 'error',
132          '@typescript-eslint/no-misused-new': 'error',
133          '@typescript-eslint/no-misused-promises': 'off',
134          '@typescript-eslint/no-namespace': 'error',
135          '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
136          '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
137          '@typescript-eslint/no-non-null-assertion': 'error',
138          '@typescript-eslint/no-redundant-type-constituents': 'error',
139          '@typescript-eslint/no-empty-object-type': 'off',
140          '@typescript-eslint/no-duplicate-enum-values': 'off',
141          '@typescript-eslint/no-unsafe-function-type': 'off',
142          'space-infix-ops': 'off',
143          '@stylistic/space-infix-ops': 'error',
144          '@stylistic/spaced-comment': [ 'error', 'always', {
145              'line': {
146                  'markers': [ '/' ],
147                  'exceptions': [ '-', '+' ]
148              },
149              'block': {
150                  'markers': [ '!' ],
151                  'exceptions': [ '*' ],
152                  'balanced': true
153              }
154          } ],
155          'object-curly-spacing': [ 'error', 'always' ],
156          '@stylistic/space-before-blocks': [ 'error', 'always' ],
157          'unused-imports/no-unused-imports': 'error',
158          'unused-imports/no-unused-vars': 'off'
159      },
160  } ] )