|
| 1 | +const { rules } = require('eslint-config-xo-typescript'); |
| 2 | + |
| 3 | +/** @type {import('prettier').Config} */ |
| 4 | +const prettierConfig = { |
| 5 | + singleQuote: true, |
| 6 | + jsxSingleQuote: false, |
| 7 | + trailingComma: 'all', |
| 8 | + endOfLine: 'auto', |
| 9 | + printWidth: 120, |
| 10 | + useTabs: true, |
| 11 | + arrowParens: 'avoid', |
| 12 | +} |
| 13 | + |
| 14 | +/** @type {import('eslint').ESLint.ConfigData} */ |
| 15 | +const config = { |
| 16 | + root: true, |
| 17 | + parser: '@typescript-eslint/parser', |
| 18 | + ignorePatterns: [ |
| 19 | + '.eslintrc.js', |
| 20 | + '*.config.js', |
| 21 | + 'node_modules/', |
| 22 | + 'dist/', |
| 23 | + 'locales/', |
| 24 | + 'public/' |
| 25 | + ], |
| 26 | + parserOptions: { |
| 27 | + project: 'tsconfig.json', |
| 28 | + tsconfigRootDir: __dirname, |
| 29 | + sourceType: 'module', |
| 30 | + }, |
| 31 | + plugins: [ |
| 32 | + '@typescript-eslint/eslint-plugin', |
| 33 | + 'mui', |
| 34 | + 'import', |
| 35 | + 'prettier' |
| 36 | + ], |
| 37 | + extends: [ |
| 38 | + 'next', |
| 39 | + 'xo', |
| 40 | + 'xo/browser', |
| 41 | + 'xo-typescript', |
| 42 | + 'plugin:import/errors', |
| 43 | + 'plugin:import/warnings' |
| 44 | + ], |
| 45 | + rules: { |
| 46 | + 'prettier/prettier': ['error', prettierConfig], |
| 47 | + '@typescript-eslint/object-curly-spacing': [ |
| 48 | + 'error', |
| 49 | + 'always' |
| 50 | + ], |
| 51 | + '@typescript-eslint/no-confusing-void-expression': 'off', |
| 52 | + '@typescript-eslint/naming-convention': ['error', |
| 53 | + { |
| 54 | + selector: 'objectLiteralProperty', |
| 55 | + filter: '^&.*', |
| 56 | + format: null, |
| 57 | + }, |
| 58 | + { |
| 59 | + selector: 'objectLiteralProperty', |
| 60 | + filter: '.*', // filter is a hack, required due to spreading default rules |
| 61 | + format: ['strictCamelCase', 'StrictPascalCase'], |
| 62 | + leadingUnderscore: 'allowSingleOrDouble', |
| 63 | + }, |
| 64 | + { |
| 65 | + selector: 'variable', |
| 66 | + filter: '.*', // filter is a hack, required due to spreading default rules |
| 67 | + format: ['strictCamelCase', 'StrictPascalCase'], |
| 68 | + leadingUnderscore: 'allowSingleOrDouble', |
| 69 | + trailingUnderscore: 'forbid' |
| 70 | + }, |
| 71 | + { |
| 72 | + selector: 'function', |
| 73 | + filter: '.*', // filter is a hack, required due to spreading default rules |
| 74 | + format: ['strictCamelCase', 'StrictPascalCase'], |
| 75 | + }, |
| 76 | + ...rules['@typescript-eslint/naming-convention'].slice(1), |
| 77 | + ], |
| 78 | + 'import/order': [ |
| 79 | + 'error', |
| 80 | + { |
| 81 | + 'groups': ['builtin', 'external', 'parent', 'sibling', 'index'], |
| 82 | + 'pathGroups': [ |
| 83 | + { |
| 84 | + pattern: '@dynogg/**', |
| 85 | + group: 'builtin', |
| 86 | + position: 'after', |
| 87 | + }, |
| 88 | + { |
| 89 | + pattern: 'react', |
| 90 | + group: 'external', |
| 91 | + position: 'before', |
| 92 | + }, |
| 93 | + { |
| 94 | + pattern: '@mui/**', |
| 95 | + group: 'external', |
| 96 | + position: 'before', |
| 97 | + }, |
| 98 | + ], |
| 99 | + distinctGroup: false, |
| 100 | + 'pathGroupsExcludedImportTypes': ['builtin'], |
| 101 | + 'newlines-between': 'always', |
| 102 | + 'alphabetize': { |
| 103 | + order: 'asc', |
| 104 | + caseInsensitive: false, |
| 105 | + }, |
| 106 | + }, |
| 107 | + ], |
| 108 | + 'jsx-quotes': ['error', 'prefer-double'], |
| 109 | + 'no-restricted-imports': ['error', { |
| 110 | + 'paths': [ |
| 111 | + { |
| 112 | + 'name': '@emotion/react', |
| 113 | + 'message': 'Please use @mui/material instead.' |
| 114 | + } |
| 115 | + ] |
| 116 | + }], |
| 117 | + 'indent': [ |
| 118 | + 'error', |
| 119 | + 'tab', |
| 120 | + { |
| 121 | + SwitchCase: 1, |
| 122 | + flatTernaryExpressions: true, |
| 123 | + FunctionDeclaration: { |
| 124 | + parameters: 'first', |
| 125 | + }, |
| 126 | + FunctionExpression: { |
| 127 | + parameters: 'first', |
| 128 | + }, |
| 129 | + ignoredNodes: ['PropertyDefinition'] |
| 130 | + }, |
| 131 | + ], |
| 132 | + '@typescript-eslint/indent': 'off', |
| 133 | + '@typescript-eslint/naming-convention': 'off', |
| 134 | + 'no-alert': 'warn', |
| 135 | + 'indent': 'off', |
| 136 | + 'no-mixed-spaces-and-tabs': 'off', |
| 137 | + '@typescript-eslint/no-explicit-any': 'error', |
| 138 | + '@typescript-eslint/ban-types': 'off', |
| 139 | + 'capitalized-comments': 'off' |
| 140 | + }, |
| 141 | +}; |
| 142 | + |
| 143 | +module.exports = config; |
0 commit comments