Skip to content

Commit 2249d5c

Browse files
committed
fixup! feat: add options to separate formatting and linting and export createConfig
1 parent ff65a38 commit 2249d5c

File tree

3 files changed

+38
-44
lines changed

3 files changed

+38
-44
lines changed

lib/configs/vue.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ export function vue(options: ConfigOptions): Linter.Config[] {
4747
files: GLOB_FILES_VUE,
4848
name: 'nextcloud/vue/rules',
4949
rules: {
50-
// PascalCase components names for vuejs
51-
'vue/component-name-in-template-casing': [
52-
'error',
53-
'PascalCase',
54-
],
55-
// space before self-closing elements
56-
'vue/html-closing-bracket-spacing': 'error',
57-
// no ending html tag on a new line
58-
'vue/html-closing-bracket-newline': [
59-
'error',
60-
{
61-
multiline: 'never',
62-
},
63-
],
6450
// Enforce documentation of properties
6551
'vue/require-prop-comment': options.isLibrary
6652
? [
@@ -83,15 +69,6 @@ export function vue(options: ConfigOptions): Linter.Config[] {
8369
'warn',
8470
'default-false',
8571
],
86-
// Allow 3 attributes on the same line if singe line
87-
'vue/max-attributes-per-line': [
88-
'error',
89-
{
90-
singleline: {
91-
max: 3,
92-
},
93-
},
94-
],
9572
// Component names should match their export names - readability and maintainability ("where does this component come from?")
9673
'vue/match-component-import-name': 'error',
9774
'vue/match-component-file-name': 'error',
@@ -141,6 +118,29 @@ export function vue(options: ConfigOptions): Linter.Config[] {
141118
// same as in the codeStyle config but for the <template> in Vue files
142119
'@nextcloud-l10n/non-breaking-space-vue': 'error',
143120
'@nextcloud-l10n/enforce-ellipsis-vue': 'error',
121+
// PascalCase components names for vuejs
122+
'vue/component-name-in-template-casing': [
123+
'error',
124+
'PascalCase',
125+
],
126+
// space before self-closing elements
127+
'vue/html-closing-bracket-spacing': 'error',
128+
// no ending html tag on a new line
129+
'vue/html-closing-bracket-newline': [
130+
'error',
131+
{
132+
multiline: 'never',
133+
},
134+
],
135+
// Allow 3 attributes on the same line if singe line
136+
'vue/max-attributes-per-line': [
137+
'error',
138+
{
139+
singleline: {
140+
max: 3,
141+
},
142+
},
143+
],
144144
// Also enforce tabs for template
145145
'vue/html-indent': [
146146
'error',

lib/configs/vue2.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,7 @@ import { vue } from './vue.ts'
1616
* @param options - Configuration options defining the config preset flavor
1717
*/
1818
export function vue2(options: ConfigOptions): Linter.Config[] {
19-
if (options.linting === false) {
20-
return []
21-
}
22-
23-
return [
24-
...restrictConfigFiles(
25-
options.linting
26-
? vuePlugin.configs['flat/vue2-recommended']
27-
: vuePlugin.configs['flat/vue2-essential'],
28-
GLOB_FILES_VUE,
29-
),
30-
31-
...vue(options),
32-
19+
const formattingRules: Linter.Config[] = [
3320
{
3421
rules: {
3522
// custom event naming convention
@@ -43,7 +30,17 @@ export function vue2(options: ConfigOptions): Linter.Config[] {
4330
],
4431
},
4532
files: GLOB_FILES_VUE,
46-
name: 'nextcloud/vue2/rules',
33+
name: 'nextcloud/vue2/stylistic-rules',
4734
},
4835
]
36+
37+
return [
38+
// the essential rules contain rules that
39+
...(options.linting && !options.formatting ? restrictConfigFiles(vuePlugin.configs['flat/vue2-essential'], GLOB_FILES_VUE) : []),
40+
...(options.linting && options.formatting ? restrictConfigFiles(vuePlugin.configs['flat/vue2-recommended'], GLOB_FILES_VUE) : []),
41+
42+
...vue(options),
43+
44+
...(options.formatting ? formattingRules : []),
45+
]
4946
}

lib/configs/vue3.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ import { vue } from './vue.ts'
1717
*/
1818
export function vue3(options: ConfigOptions): Linter.Config[] {
1919
return [
20-
...restrictConfigFiles(
21-
options.linting
22-
? vuePlugin.configs['flat/recommended']
23-
: vuePlugin.configs['flat/essential'],
24-
GLOB_FILES_VUE,
25-
),
20+
// the essential rules contain rules that
21+
...(options.linting && !options.formatting ? restrictConfigFiles(vuePlugin.configs['flat/essential'], GLOB_FILES_VUE) : []),
22+
...(options.linting && options.formatting ? restrictConfigFiles(vuePlugin.configs['flat/recommended'], GLOB_FILES_VUE) : []),
2623

2724
...vue(options),
2825

0 commit comments

Comments
 (0)