Created
September 15, 2026 03:12
-
-
Save JBreit/b1c75936cae26630b2efec047dd2a681 to your computer and use it in GitHub Desktop.
eslint config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { dirname } from 'node:path'; | |
| import { env } from 'node:process'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { FlatCompat } from '@eslint/eslintrc'; | |
| import eslint from '@eslint/js'; | |
| import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; | |
| import globals from 'globals'; | |
| // import importPlugin from 'eslint-plugin-import'; | |
| import { importX } from 'eslint-plugin-import-x' | |
| import jestPlugin from 'eslint-plugin-jest'; | |
| // import stylisticPlugin from '@stylistic/eslint-plugin'; | |
| import parser from '@typescript-eslint/parser'; | |
| import tseslint from 'typescript-eslint'; | |
| const __dirname = dirname(fileURLToPath(import.meta.url)); | |
| const OFF = 0; | |
| const WARNING = 1; | |
| const ERROR = 2; | |
| const compat = new FlatCompat({ | |
| baseDirectory: import.meta.dirname, | |
| resolvePluginsRelativeTo: import.meta.dirname, | |
| }); | |
| const extensions = [ | |
| '.cjs', | |
| '.cts', | |
| '.js', | |
| '.json', | |
| '.jsx', | |
| '.mjs', | |
| '.mts', | |
| '.node', | |
| '.ts', | |
| '.tsx', | |
| '*.d.cts', | |
| '*.d.mts', | |
| '*.d.ts', | |
| ]; | |
| const jest = { | |
| plugin: jestPlugin, | |
| }; | |
| export default [ | |
| // eslint.configs.recommended, | |
| ...tseslint.configs.recommendedTypeChecked, | |
| ...tseslint.configs.stylisticTypeChecked, | |
| eslintPluginPrettierRecommended, | |
| importX.flatConfigs.recommended, | |
| importX.flatConfigs.typescript, | |
| { | |
| ignores: [ | |
| '{certs,coverage,dist,docs,e2e,examples,logs,node_modules,scripts,temp,tools}/*', | |
| '**/dist/*', | |
| '.{bin,certs,changeset,config,docker,github, gitmodules,husky,ssh,vscode,vscode-test}/*', | |
| '{CHANGELOG,TODO}.md', | |
| '**/*.config.{cjs,js,mjs,ts}', | |
| '**/*.d.{cts,mts,ts}', | |
| '**/*.spec.{cjs,cts,js,jsx,mjs,mts,ts,tsx}', | |
| '**/.*', | |
| '.*', | |
| ], | |
| }, | |
| { | |
| languageOptions: { | |
| globals: { ...globals.node }, | |
| sourceType: 'module', | |
| }, | |
| linterOptions: { | |
| reportUnusedDisableDirectives: true, | |
| }, | |
| }, | |
| { | |
| files: ['**/*.{cts,mts,ts,tsx}', '**/*.spec.{cts,mts,ts,tsx}'], | |
| languageOptions: { | |
| parser, | |
| parserOptions: { | |
| ecmaFeatures: { | |
| experimentalObjectRestSpread: true, | |
| impliedStrict: true, | |
| jsx: true, | |
| modules: true, | |
| }, | |
| ecmaVersion: 2024, | |
| emitDecoratorMetadata: true, | |
| project: [ | |
| import.meta.resolve(`${import.meta.dirname}/packages/*/tsconfig.lib.json`), | |
| import.meta.resolve(`${import.meta.dirname}/tsconfig.eslint.json`), | |
| import.meta.resolve(`${import.meta.dirname}/tsconfig.test.json`), | |
| import.meta.resolve(`${import.meta.dirname}/tsconfig.json`), | |
| ], | |
| projectService: false, | |
| sourceType: 'module', | |
| tsconfigRootDir: import.meta.dirname, | |
| warnOnUnsupportedTypeScriptVersion: true, | |
| }, | |
| }, | |
| plugins: { | |
| // '@typescript-eslint': tseslint.plugin, | |
| // js: eslint, | |
| 'import-x': importX | |
| }, | |
| }, | |
| // env.NODE_ENV === 'test' ? jestPlugin.configs['flat/recommended']: {}, | |
| // { | |
| // files: ['**/*.spec.{cts,mts,ts,tsx}'], | |
| // languageOptions: { | |
| // globals: { | |
| // expect: 'readonly', | |
| // describe: 'readonly', | |
| // it: 'readonly', | |
| // }, | |
| // }, | |
| // }, | |
| { | |
| rules: { | |
| 'constructor-super': OFF, | |
| 'comma-spacing': [ | |
| ERROR, | |
| { | |
| before: false, | |
| after: true, | |
| }, | |
| ], | |
| eqeqeq: [ERROR, 'smart'], | |
| 'getter-return': OFF, | |
| 'implicit-arrow-linebreak': OFF, | |
| 'import-x/default': OFF, | |
| 'import-x/export': OFF, | |
| 'import-x/extensions': [ | |
| ERROR, | |
| { | |
| ignorePackages: true, | |
| pattern: { | |
| cjs: 'never', | |
| js: 'always', | |
| json: 'always', | |
| jsx: 'never', | |
| mjs: 'never', | |
| ts: 'never', | |
| tsx: 'never', | |
| }, | |
| }, | |
| ], | |
| 'import-x/no-extraneous-dependencies': [ | |
| ERROR, | |
| { | |
| // devDependencies: ['**/*.spec.ts'], | |
| devDependencies: true, | |
| optionalDependencies: false, | |
| peerDependencies: true, | |
| // bundleDependencies: true, | |
| // packageDir: [import.meta.resolve(`${import.meta.dirname}/packages/cli`)], | |
| }, | |
| ], | |
| 'import-x/named': OFF, | |
| 'import-x/namespace': OFF, | |
| 'import-x/no-named-as-default': OFF, | |
| 'import-x/no-named-as-default-member': OFF, | |
| 'import-x/no-duplicates': OFF, | |
| 'import-x/no-unresolved': OFF, | |
| 'import-x/order': [ | |
| ERROR, | |
| { | |
| groups: [ | |
| 'builtin', | |
| 'external', | |
| 'internal', | |
| 'unknown', | |
| 'parent', | |
| 'sibling', | |
| 'index', | |
| 'object', | |
| 'type', | |
| ], | |
| 'newlines-between': 'always-and-inside-groups', | |
| alphabetize: { | |
| order: 'asc', // asc | desc | ignore | |
| orderImportKind: 'asc', // asc | desc | ignore | |
| caseInsensitive: true, | |
| }, | |
| }, | |
| ], | |
| 'import-x/prefer-default-export': OFF, | |
| 'linebreak-style': [ | |
| ERROR, | |
| process.platform === 'win32' ? 'windows' : 'unix', | |
| ], | |
| 'jsx-quotes': [ERROR, 'prefer-single'], | |
| 'no-alert': process.env.NODE_ENV === 'production' ? ERROR : OFF, | |
| 'no-console': process.env.NODE_ENV === 'production' ? ERROR : OFF, | |
| 'no-const-assign': OFF, | |
| 'no-debugger': process.env.NODE_ENV === 'production' ? ERROR : OFF, | |
| 'no-dupe-args': OFF, | |
| 'no-dupe-class-members': OFF, | |
| 'no-dupe-keys': OFF, | |
| 'no-dynamic-require': OFF, | |
| 'no-func-assign': OFF, | |
| 'no-implied-eval': OFF, | |
| 'no-import-assign': OFF, | |
| 'no-new-symbol': OFF, | |
| 'no-obj-calls': OFF, | |
| 'no-redeclare': OFF, | |
| 'no-restricted-globals': OFF, | |
| 'no-setter-return': OFF, | |
| 'no-this-before-super': OFF, | |
| 'no-undef': OFF, | |
| 'no-underscore-dangle': [ | |
| ERROR, | |
| { | |
| allow: [ | |
| '_aggregateId', | |
| '_app', | |
| '_basePath', | |
| '_client', | |
| '_context', | |
| '_createdAt', | |
| '_domainEvents', | |
| '_events', | |
| '_id', | |
| '_instance', | |
| '_mutex', | |
| '_response', | |
| '_request', | |
| '_router', | |
| '_routes', | |
| '_server', | |
| '_sharedArrayBuffer', | |
| '_subscribers', | |
| '_timestamp', | |
| '_updatedAt', | |
| '_waitGroup', | |
| '_value', | |
| '__filename', | |
| '__dirname', | |
| '__lock', | |
| '__nonce__', | |
| '__WB_MANIFEST', | |
| ], | |
| }, | |
| ], | |
| 'no-unreachable': OFF, | |
| 'no-unsafe-negation': OFF, | |
| 'no-unused-expressions': [ | |
| ERROR, | |
| { | |
| allowShortCircuit: true, | |
| allowTernary: true, | |
| allowTaggedTemplates: true, | |
| }, | |
| ], | |
| 'no-unused-private-class-members': ERROR, | |
| semi: [ERROR, 'always'], | |
| 'space-before-function-paren': [ | |
| ERROR, | |
| { | |
| anonymous: 'ignore', | |
| named: 'ignore', | |
| asyncArrow: 'always', | |
| }, | |
| ], | |
| 'space-in-parens': [ERROR, 'never'], | |
| 'valid-typeof': OFF, | |
| '@typescript-eslint/ban-types': OFF, | |
| '@typescript-eslint/ban-ts-ignore': OFF, | |
| '@typescript-eslint/ban-ts-comment': [ | |
| ERROR, | |
| { | |
| 'ts-ignore': false, | |
| }, | |
| ], | |
| 'comma-dangle': OFF, | |
| '@typescript-eslint/comma-dangle': OFF, | |
| '@typescript-eslint/consistent-type-exports': [ | |
| ERROR, | |
| { | |
| fixMixedExportsWithInlineTypeSpecifier: false, | |
| }, | |
| ], | |
| '@typescript-eslint/naming-convention': [ | |
| ERROR, | |
| { | |
| format: ['strictCamelCase'], | |
| leadingUnderscore: 'allowDouble', | |
| selector: [], | |
| }, | |
| ], | |
| '@typescript-eslint/no-empty-object-type': [ | |
| ERROR, | |
| { | |
| allowInterfaces: 'always', | |
| }, | |
| ], | |
| '@typescript-eslint/no-namespace': [ | |
| ERROR, | |
| { | |
| allowDeclarations: true, | |
| allowDefinitionFiles: true, | |
| }, | |
| ], | |
| 'no-unused-vars': OFF, | |
| '@typescript-eslint/no-unused-vars': [ | |
| ERROR, | |
| { | |
| args: 'after-used', | |
| argsIgnorePattern: '(^reject$|^_|^_$)', | |
| vars: 'all', | |
| varsIgnorePattern: '(^_$|^_|^h$)', | |
| }, | |
| ], | |
| 'no-use-before-define': OFF, | |
| '@typescript-eslint/no-use-before-define': [ | |
| ERROR, | |
| { | |
| classes: false, | |
| functions: false, | |
| }, | |
| ], | |
| 'no-throw-literal': OFF, | |
| '@typescript-eslint/only-throw-error': ERROR, | |
| '@typescript-eslint/prefer-nullish-coalescing': ERROR, | |
| '@typescript-eslint/return-await': [ERROR, 'in-try-catch'], | |
| '@typescript-eslint/restrict-template-expressions': [ | |
| ERROR, | |
| { | |
| allowNever: true, | |
| }, | |
| ], | |
| // '@stylistic/comma-spacing': [ ERROR, { before: false, after: true }], | |
| // '@stylistic/indent': [ | |
| // ERROR, | |
| // 2, | |
| // { | |
| // SwitchCase: WARNING, | |
| // }, | |
| // ], | |
| }, | |
| }, | |
| { | |
| settings: { | |
| 'import/extensions': extensions, | |
| 'import/parser': { | |
| '@typescript-eslint/parser': ['.cts', '.mts', '.ts', '.tsx'], | |
| }, | |
| 'import/resolver': { | |
| node: { | |
| extensions, | |
| moduleDirectory: [ | |
| import.meta.resolve(`${import.meta.dirname}/apps/*`), | |
| import.meta.resolve(`${import.meta.dirname}/packages/*`), | |
| import.meta.resolve(`${import.meta.dirname}/node_modules`), | |
| ], | |
| }, | |
| typescript: { | |
| alwaysTryTypes: true, | |
| }, | |
| }, | |
| }, | |
| }, | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment