Skip to content

Commit 1f58713

Browse files
committed
chore: wip
1 parent 91d602c commit 1f58713

File tree

15 files changed

+76
-71
lines changed

15 files changed

+76
-71
lines changed

.stacks/core/eslint-config/src/configs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export * from './unicorn'
1313
export * from './vue'
1414
export * from './yaml'
1515
export * from './test'
16-
export * from './sort-keys'
16+
export * from './perfectionist'

.stacks/core/eslint-config/src/configs/javascript.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
4242
'accessor-pairs': ['error', { enforceForClassMembers: true, setWithoutGet: true }],
4343

4444
'array-callback-return': 'error',
45-
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
4645
'block-scoped-var': 'error',
4746
'constructor-super': 'error',
4847
'default-case-last': 'error',
@@ -158,7 +157,6 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
158157
'no-useless-rename': 'error',
159158
'no-useless-return': 'error',
160159
'no-var': 'error',
161-
'no-void': 'error',
162160
'no-with': 'error',
163161
'object-shorthand': [
164162
'error',

.stacks/core/eslint-config/src/configs/jsonc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { parserJsonc, pluginJsonc } from '../plugins'
44

55
export function jsonc(options: OptionsStylistic & OptionsOverrides = {}): ConfigItem[] {
66
const {
7-
stylistic = true,
87
overrides = {},
8+
stylistic = true,
99
} = options
1010

1111
const {

.stacks/core/eslint-config/src/configs/markdown.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@ export function markdown(options: OptionsComponentExts & OptionsOverrides = {}):
3737
'antfu/no-cjs-exports': 'off',
3838
'antfu/no-ts-export-equal': 'off',
3939

40+
'import/newline-after-import': 'off',
41+
4042
'no-alert': 'off',
4143
'no-console': 'off',
4244
'no-undef': 'off',
4345
'no-unused-expressions': 'off',
46+
4447
'no-unused-vars': 'off',
4548

4649
'node/prefer-global/process': 'off',
47-
4850
'style/comma-dangle': 'off',
49-
'style/eol-last': 'off',
5051

52+
'style/eol-last': 'off',
5153
'ts/consistent-type-imports': 'off',
5254
'ts/no-namespace': 'off',
5355
'ts/no-redeclare': 'off',
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { ConfigItem } from '../types'
2+
import { pluginPerfectionist } from '../plugins'
3+
4+
/**
5+
* Optional perfectionist plugin for props and items sorting.
6+
*
7+
* @see https://github.com/azat-io/eslint-plugin-perfectionist
8+
*/
9+
export function perfectionist(): ConfigItem[] {
10+
return [
11+
{
12+
name: 'antfu:perfectionist',
13+
plugins: {
14+
perfectionist: pluginPerfectionist,
15+
},
16+
},
17+
]
18+
}

.stacks/core/eslint-config/src/configs/sort-keys.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

.stacks/core/eslint-config/src/configs/stylistic.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { pluginAntfu, pluginStylistic } from '../plugins'
44
export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
55
const {
66
indent = 2,
7-
quotes = 'single',
87
jsx = true,
8+
quotes = 'single',
99
} = options
1010

1111
return [
@@ -23,6 +23,7 @@ export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
2323
'curly': ['error', 'multi-or-nest', 'consistent'],
2424

2525
'style/array-bracket-spacing': ['error', 'never'],
26+
'style/arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
2627
'style/arrow-spacing': ['error', { after: true, before: true }],
2728
'style/block-spacing': ['error', 'always'],
2829
'style/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
@@ -35,14 +36,9 @@ export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
3536
'style/indent': ['error', indent, {
3637
ArrayExpression: 1,
3738
CallExpression: { arguments: 1 },
39+
flatTernaryExpressions: false,
3840
FunctionDeclaration: { body: 1, parameters: 1 },
3941
FunctionExpression: { body: 1, parameters: 1 },
40-
ImportDeclaration: 1,
41-
MemberExpression: 1,
42-
ObjectExpression: 1,
43-
SwitchCase: 1,
44-
VariableDeclarator: 1,
45-
flatTernaryExpressions: false,
4642
ignoreComments: false,
4743
ignoredNodes: [
4844
'TemplateLiteral *',
@@ -67,10 +63,14 @@ export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
6763
'FunctionExpression > .params > :matches(Decorator, :not(:first-child))',
6864
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key',
6965
],
66+
ImportDeclaration: 1,
67+
MemberExpression: 1,
68+
ObjectExpression: 1,
7069
offsetTernaryExpressions: true,
7170
outerIIFEBody: 1,
71+
SwitchCase: 1,
72+
VariableDeclarator: 1,
7273
}],
73-
7474
'style/key-spacing': ['error', { afterColon: true, beforeColon: false }],
7575
'style/keyword-spacing': ['error', { after: true, before: true }],
7676
'style/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
@@ -95,7 +95,6 @@ export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
9595
'style/no-trailing-spaces': 'error',
9696
'style/no-whitespace-before-property': 'error',
9797
'style/object-curly-spacing': ['error', 'always'],
98-
'style/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
9998
'style/operator-linebreak': ['error', 'before'],
10099
'style/padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }],
101100
'style/quote-props': ['error', 'consistent-as-needed'],

.stacks/core/eslint-config/src/configs/typescript.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import process from 'node:process'
2+
import type { ConfigItem, OptionsComponentExts, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from '../types'
23
import { GLOB_SRC } from '../globs'
34
import { parserTs, pluginAntfu, pluginImport, pluginTs } from '../plugins'
4-
import type { ConfigItem, OptionsComponentExts, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from '../types'
5-
import { renameRules } from '../utils'
5+
import { renameRules, toArray } from '../utils'
66

77
export function typescript(
88
options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions,
@@ -11,7 +11,6 @@ export function typescript(
1111
componentExts = [],
1212
overrides = {},
1313
parserOptions = {},
14-
tsconfigPath,
1514
} = options ?? {}
1615

1716
const typeAwareRules: ConfigItem['rules'] = {
@@ -36,6 +35,10 @@ export function typescript(
3635
'ts/unbound-method': 'error',
3736
}
3837

38+
const tsconfigPath = options?.tsconfigPath
39+
? toArray(options.tsconfigPath)
40+
: undefined
41+
3942
return [
4043
{
4144
// Install the plugins without globs, so they can be configured separately.
@@ -54,10 +57,11 @@ export function typescript(
5457
languageOptions: {
5558
parser: parserTs,
5659
parserOptions: {
60+
extraFileExtensions: componentExts.map(ext => `.${ext}`),
5761
sourceType: 'module',
5862
...tsconfigPath
5963
? {
60-
project: [tsconfigPath],
64+
project: tsconfigPath,
6165
tsconfigRootDir: process.cwd(),
6266
}
6367
: {},

.stacks/core/eslint-config/src/configs/vue.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ export function vue(
4747
'vue/block-order': ['error', {
4848
order: ['script', 'template', 'style'],
4949
}],
50-
'vue/component-name-in-template-casing': ['error', 'PascalCase', {
51-
registeredComponentsOnly: false,
52-
}],
50+
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
5351
'vue/component-options-name-casing': ['error', 'PascalCase'],
5452
'vue/custom-event-name-casing': ['error', 'camelCase'],
5553
'vue/define-macros-order': ['error', {
@@ -89,6 +87,7 @@ export function vue(
8987
],
9088
'vue/prefer-separate-static-class': 'error',
9189
'vue/prefer-template': 'error',
90+
'vue/prop-name-casing': ['error', 'camelCase'],
9291
'vue/require-default-prop': 'off',
9392
'vue/require-prop-types': 'off',
9493
'vue/space-infix-ops': 'error',

.stacks/core/eslint-config/src/factory.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
jsonc,
1313
markdown,
1414
node,
15-
sortKeys,
15+
perfectionist,
1616
sortPackageJson,
1717
sortTsconfig,
1818
stylistic,
@@ -47,12 +47,12 @@ const VuePackages = [
4747
*/
4848
export function antfu(options: OptionsConfig & ConfigItem = {}, ...userConfigs: (ConfigItem | ConfigItem[])[]) {
4949
const {
50-
isInEditor = !!((process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI),
51-
vue: enableVue = VuePackages.some(i => isPackageExists(i)),
52-
typescript: enableTypeScript = isPackageExists('typescript'),
50+
componentExts = [],
5351
gitignore: enableGitignore = true,
52+
isInEditor = !!((process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI),
5453
overrides = {},
55-
componentExts = [],
54+
typescript: enableTypeScript = isPackageExists('typescript'),
55+
vue: enableVue = VuePackages.some(i => isPackageExists(i)),
5656
} = options
5757

5858
const stylisticOptions = options.stylistic === false
@@ -92,8 +92,8 @@ export function antfu(options: OptionsConfig & ConfigItem = {}, ...userConfigs:
9292
}),
9393
unicorn(),
9494

95-
// Optional plugins (not enabled by default)
96-
sortKeys(),
95+
// Optional plugins (installed but not enabled by default)
96+
perfectionist(),
9797
)
9898

9999
if (enableVue)

0 commit comments

Comments
 (0)