|
| 1 | +import next from '@next/eslint-plugin-next'; |
| 2 | +import { defineConfig } from '@soybeanjs/eslint-config'; |
| 3 | +import sort from 'eslint-plugin-sort'; |
| 4 | + |
| 5 | +const config = defineConfig( |
| 6 | + { |
| 7 | + prettierRules: { |
| 8 | + singleAttributePerLine: true, |
| 9 | + trailingCommas: 'none' |
| 10 | + }, |
| 11 | + react: true |
| 12 | + }, |
| 13 | + sort.configs['flat/recommended'], |
| 14 | + { |
| 15 | + plugins: { |
| 16 | + next |
| 17 | + }, |
| 18 | + rules: { |
| 19 | + 'import/newline-after-import': 'error', |
| 20 | + 'import/no-absolute-path': 'warn', |
| 21 | + 'import/no-empty-named-blocks': ['error'], |
| 22 | + 'import/no-useless-path-segments': [ |
| 23 | + 'error', |
| 24 | + { |
| 25 | + noUselessIndex: true |
| 26 | + } |
| 27 | + ], |
| 28 | + |
| 29 | + 'import/order': [ |
| 30 | + 'error', |
| 31 | + { |
| 32 | + alphabetize: { |
| 33 | + order: 'asc' |
| 34 | + }, |
| 35 | + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'], |
| 36 | + 'newlines-between': 'always', |
| 37 | + pathGroups: [{ group: 'internal', pattern: '{{@,~}/,#}**' }], |
| 38 | + pathGroupsExcludedImportTypes: ['builtin'] |
| 39 | + } |
| 40 | + ], |
| 41 | + |
| 42 | + 'no-underscore-dangle': 'off', |
| 43 | + |
| 44 | + 'react/hook-use-state': [ |
| 45 | + 'error', // or "warn" to only warn instead of error |
| 46 | + { |
| 47 | + allowDestructuredState: true |
| 48 | + } |
| 49 | + ], |
| 50 | + |
| 51 | + 'react/jsx-closing-bracket-location': ['warn', 'tag-aligned'], |
| 52 | + 'react/jsx-closing-tag-location': 'warn', |
| 53 | + 'react/jsx-curly-brace-presence': [ |
| 54 | + 'warn', |
| 55 | + { |
| 56 | + children: 'never', |
| 57 | + propElementValues: 'always', |
| 58 | + props: 'never' |
| 59 | + } |
| 60 | + ], |
| 61 | + 'react/jsx-curly-newline': ['warn', { multiline: 'consistent', singleline: 'consistent' }], |
| 62 | + 'react/jsx-equals-spacing': ['warn', 'never'], |
| 63 | + 'react/jsx-fragments': ['warn', 'syntax'], |
| 64 | + 'react/jsx-newline': 'warn', |
| 65 | + 'react/jsx-no-undef': ['off'], |
| 66 | + 'react/jsx-no-useless-fragment': 'warn', |
| 67 | + 'react/jsx-one-expression-per-line': [ |
| 68 | + 'warn', |
| 69 | + { |
| 70 | + allow: 'single-child' |
| 71 | + } |
| 72 | + ], |
| 73 | + 'react/jsx-props-no-multi-spaces': 'warn', |
| 74 | + 'react/jsx-sort-props': [ |
| 75 | + 'warn', |
| 76 | + { callbacksLast: true, ignoreCase: true, multiline: 'last', shorthandFirst: true } |
| 77 | + ], |
| 78 | + 'react/self-closing-comp': [ |
| 79 | + 'error', |
| 80 | + { |
| 81 | + component: true, |
| 82 | + html: true |
| 83 | + } |
| 84 | + ], |
| 85 | + 'react-refresh/only-export-components': 'off', |
| 86 | + 'sort/import-members': ['error', { caseSensitive: true, natural: true }], |
| 87 | + 'sort/imports': ['off'], |
| 88 | + 'sort/string-enums': ['error', { caseSensitive: false, natural: true }], |
| 89 | + 'sort/string-unions': ['error', { caseSensitive: false, natural: true }], |
| 90 | + 'sort/type-properties': ['warn', { caseSensitive: false, natural: true }], |
| 91 | + 'sort/type-properties': ['error', { caseSensitive: false, natural: true }] |
| 92 | + } |
| 93 | + } |
| 94 | +); |
| 95 | + |
| 96 | +const eslintConfig = config; |
| 97 | + |
| 98 | +export default eslintConfig; |
0 commit comments