| 1 | // eslint-disable-next-line n/no-unpublished-require |
| 2 | const { defineConfig } = require('eslint-define-config') |
| 3 | |
| 4 | module.exports = defineConfig({ |
| 5 | root: true, |
| 6 | env: { |
| 7 | es2022: true, |
| 8 | node: true |
| 9 | }, |
| 10 | parserOptions: { |
| 11 | ecmaVersion: 2022, |
| 12 | sourceType: 'module' |
| 13 | }, |
| 14 | plugins: ['import'], |
| 15 | extends: ['eslint:recommended', 'plugin:import/recommended'], |
| 16 | settings: { |
| 17 | 'import/resolver': { |
| 18 | typescript: { |
| 19 | project: './tsconfig.json' |
| 20 | } |
| 21 | } |
| 22 | }, |
| 23 | rules: { |
| 24 | 'sort-imports': [ |
| 25 | 'error', |
| 26 | { |
| 27 | ignoreCase: false, |
| 28 | ignoreDeclarationSort: true, |
| 29 | ignoreMemberSort: false, |
| 30 | memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], |
| 31 | allowSeparatedGroups: true |
| 32 | } |
| 33 | ], |
| 34 | 'import/order': [ |
| 35 | 'error', |
| 36 | { |
| 37 | groups: [ |
| 38 | 'builtin', // Built-in imports (come from NodeJS native) go first |
| 39 | 'external', // <- External imports |
| 40 | 'internal', // <- Absolute imports |
| 41 | ['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together |
| 42 | 'index', // <- Index imports |
| 43 | 'unknown' // <- Unknown |
| 44 | ], |
| 45 | 'newlines-between': 'always', |
| 46 | alphabetize: { |
| 47 | /* Sort in ascending order. Options: ["ignore", "asc", "desc"] */ |
| 48 | order: 'asc', |
| 49 | /* Ignore case. Options: [true, false] */ |
| 50 | caseInsensitive: true |
| 51 | } |
| 52 | } |
| 53 | ] |
| 54 | }, |
| 55 | overrides: [ |
| 56 | { |
| 57 | files: ['**/*.ts'], |
| 58 | parser: '@typescript-eslint/parser', |
| 59 | parserOptions: { |
| 60 | project: './tsconfig.json' |
| 61 | }, |
| 62 | plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'], |
| 63 | extends: [ |
| 64 | 'plugin:@typescript-eslint/strict-type-checked', |
| 65 | 'plugin:@typescript-eslint/stylistic-type-checked', |
| 66 | 'plugin:import/typescript', |
| 67 | 'standard-with-typescript' |
| 68 | ], |
| 69 | rules: { |
| 70 | 'operator-linebreak': 'off', |
| 71 | 'tsdoc/syntax': 'warn' |
| 72 | } |
| 73 | }, |
| 74 | { |
| 75 | files: ['**/*.js', '**/*.cjs', '**/*.mjs'], |
| 76 | plugins: ['jsdoc'], |
| 77 | extends: ['plugin:n/recommended', 'plugin:jsdoc/recommended', 'standard'], |
| 78 | rules: { |
| 79 | 'n/shebang': 'off' |
| 80 | } |
| 81 | } |
| 82 | ] |
| 83 | }) |