|
| 1 | +// @ts-check |
| 2 | +const { builtinModules } = require('node:module') |
| 3 | +const { defineConfig } = require('eslint-define-config') |
| 4 | + |
| 5 | +module.exports = defineConfig({ |
| 6 | + root: true, |
| 7 | + extends: [ |
| 8 | + 'eslint:recommended', |
| 9 | + 'plugin:n/recommended', |
| 10 | + 'plugin:@typescript-eslint/recommended', |
| 11 | + 'plugin:regexp/recommended', |
| 12 | + ], |
| 13 | + ignorePatterns: ['packages/create-quarkc/template-**'], |
| 14 | + plugins: ['import', 'regexp'], |
| 15 | + parser: '@typescript-eslint/parser', |
| 16 | + parserOptions: { |
| 17 | + sourceType: 'module', |
| 18 | + ecmaVersion: 2021, |
| 19 | + }, |
| 20 | + rules: { |
| 21 | + eqeqeq: ['warn', 'always', { null: 'never' }], |
| 22 | + 'no-debugger': ['error'], |
| 23 | + 'no-empty': ['warn', { allowEmptyCatch: true }], |
| 24 | + 'no-process-exit': 'off', |
| 25 | + 'no-useless-escape': 'off', |
| 26 | + 'prefer-const': [ |
| 27 | + 'warn', |
| 28 | + { |
| 29 | + destructuring: 'all', |
| 30 | + }, |
| 31 | + ], |
| 32 | + |
| 33 | + 'n/no-process-exit': 'off', |
| 34 | + 'n/no-missing-import': 'off', |
| 35 | + 'n/no-missing-require': [ |
| 36 | + 'error', |
| 37 | + { |
| 38 | + // for try-catching yarn pnp |
| 39 | + allowModules: ['pnpapi', 'quarkc'], |
| 40 | + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], |
| 41 | + }, |
| 42 | + ], |
| 43 | + 'n/no-extraneous-import': [ |
| 44 | + 'error', |
| 45 | + { |
| 46 | + allowModules: ['quarkc', 'less', 'sass', 'unbuild'], |
| 47 | + }, |
| 48 | + ], |
| 49 | + 'n/no-extraneous-require': [ |
| 50 | + 'error', |
| 51 | + { |
| 52 | + allowModules: ['vite'], |
| 53 | + }, |
| 54 | + ], |
| 55 | + 'n/no-deprecated-api': 'off', |
| 56 | + 'n/no-unpublished-import': 'off', |
| 57 | + 'n/no-unpublished-require': 'off', |
| 58 | + 'n/no-unsupported-features/es-syntax': 'off', |
| 59 | + |
| 60 | + '@typescript-eslint/ban-ts-comment': 'error', |
| 61 | + '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR |
| 62 | + '@typescript-eslint/explicit-module-boundary-types': [ |
| 63 | + 'error', |
| 64 | + { allowArgumentsExplicitlyTypedAsAny: true }, |
| 65 | + ], |
| 66 | + '@typescript-eslint/no-empty-function': [ |
| 67 | + 'error', |
| 68 | + { allow: ['arrowFunctions'] }, |
| 69 | + ], |
| 70 | + '@typescript-eslint/no-empty-interface': 'off', |
| 71 | + '@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR |
| 72 | + '@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier |
| 73 | + '@typescript-eslint/no-inferrable-types': 'off', |
| 74 | + '@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR |
| 75 | + '@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR |
| 76 | + '@typescript-eslint/no-var-requires': 'off', |
| 77 | + '@typescript-eslint/consistent-type-imports': [ |
| 78 | + 'error', |
| 79 | + { prefer: 'type-imports' }, |
| 80 | + ], |
| 81 | + |
| 82 | + 'import/no-nodejs-modules': [ |
| 83 | + 'error', |
| 84 | + { allow: builtinModules.map((mod) => `node:${mod}`) }, |
| 85 | + ], |
| 86 | + 'import/no-duplicates': 'error', |
| 87 | + 'import/order': 'error', |
| 88 | + 'sort-imports': [ |
| 89 | + 'error', |
| 90 | + { |
| 91 | + ignoreCase: false, |
| 92 | + ignoreDeclarationSort: true, |
| 93 | + ignoreMemberSort: false, |
| 94 | + memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], |
| 95 | + allowSeparatedGroups: false, |
| 96 | + }, |
| 97 | + ], |
| 98 | + |
| 99 | + 'regexp/no-contradiction-with-assertion': 'error', |
| 100 | + }, |
| 101 | + overrides: [ |
| 102 | + { |
| 103 | + files: ['packages/**'], |
| 104 | + excludedFiles: '**/__tests__/**', |
| 105 | + rules: { |
| 106 | + 'no-restricted-globals': [ |
| 107 | + 'error', |
| 108 | + 'require', |
| 109 | + '__dirname', |
| 110 | + '__filename', |
| 111 | + ], |
| 112 | + }, |
| 113 | + }, |
| 114 | + { |
| 115 | + files: ['packages/create-quarkc/template-*/**', '**/build.config.ts'], |
| 116 | + rules: { |
| 117 | + 'no-undef': 'off', |
| 118 | + 'n/no-missing-import': 'off', |
| 119 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 120 | + }, |
| 121 | + }, |
| 122 | + { |
| 123 | + files: ['*.js', '*.mjs', '*.cjs'], |
| 124 | + rules: { |
| 125 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 126 | + }, |
| 127 | + }, |
| 128 | + { |
| 129 | + files: ['*.d.ts'], |
| 130 | + rules: { |
| 131 | + '@typescript-eslint/triple-slash-reference': 'off', |
| 132 | + }, |
| 133 | + }, |
| 134 | + ], |
| 135 | + reportUnusedDisableDirectives: true, |
| 136 | +}) |
0 commit comments