@nextcloud/eslint-config 9.0.0-rc.0 → 9.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -40
- package/README.md +142 -29
- package/dist/configs/codeStyle.d.ts +13 -0
- package/dist/configs/codeStyle.js +184 -0
- package/dist/configs/documentation.d.ts +12 -0
- package/dist/configs/documentation.js +123 -0
- package/dist/configs/filesystem.d.ts +9 -0
- package/dist/configs/filesystem.js +20 -0
- package/dist/configs/imports.d.ts +12 -0
- package/dist/configs/imports.js +114 -0
- package/dist/configs/javascript.d.ts +14 -0
- package/dist/configs/javascript.js +118 -0
- package/dist/configs/json.d.ts +9 -0
- package/dist/configs/json.js +45 -0
- package/dist/configs/node.d.ts +10 -0
- package/dist/configs/node.js +24 -0
- package/dist/configs/typescript.d.ts +12 -0
- package/dist/configs/typescript.js +60 -0
- package/dist/configs/vue.d.ts +12 -0
- package/dist/configs/vue.js +152 -0
- package/dist/configs/vue2.d.ts +12 -0
- package/dist/configs/vue2.js +30 -0
- package/dist/configs/vue3.d.ts +12 -0
- package/dist/configs/vue3.js +26 -0
- package/dist/globs.d.ts +20 -0
- package/dist/globs.js +39 -0
- package/dist/index.d.ts +27 -31
- package/dist/index.js +78 -0
- package/dist/plugins/l10n/index.d.ts +10 -0
- package/dist/plugins/l10n/index.js +17 -0
- package/dist/plugins/l10n/rules/enforce-ellipsis.d.ts +7 -0
- package/dist/plugins/l10n/rules/enforce-ellipsis.js +32 -0
- package/dist/plugins/l10n/rules/non-breaking-space.d.ts +7 -0
- package/dist/plugins/l10n/rules/non-breaking-space.js +30 -0
- package/dist/plugins/nextcloud/index.d.ts +7 -0
- package/dist/plugins/nextcloud/index.js +9 -0
- package/dist/plugins/nextcloud/rules/index.d.ts +6 -0
- package/dist/plugins/nextcloud/rules/index.js +6 -0
- package/dist/plugins/nextcloud/rules/no-deprecations.d.ts +7 -0
- package/dist/plugins/nextcloud/rules/no-deprecations.js +196 -0
- package/dist/plugins/nextcloud/rules/no-removed-apis.d.ts +7 -0
- package/dist/plugins/nextcloud/rules/no-removed-apis.js +152 -0
- package/dist/plugins/nextcloud/utils/version-parser.d.ts +41 -0
- package/dist/plugins/nextcloud/utils/version-parser.js +106 -0
- package/dist/plugins/nextcloud-vue/index.d.ts +28 -0
- package/dist/plugins/nextcloud-vue/index.js +13 -0
- package/dist/plugins/nextcloud-vue/rules/index.d.ts +17 -0
- package/dist/plugins/nextcloud-vue/rules/index.js +10 -0
- package/dist/plugins/nextcloud-vue/rules/no-deprecated-exports.d.ts +7 -0
- package/dist/plugins/nextcloud-vue/rules/no-deprecated-exports.js +44 -0
- package/dist/plugins/nextcloud-vue/rules/no-deprecated-props.d.ts +20 -0
- package/dist/plugins/nextcloud-vue/rules/no-deprecated-props.js +61 -0
- package/dist/plugins/nextcloud-vue/utils/lib-version-parser.d.ts +33 -0
- package/dist/plugins/nextcloud-vue/utils/lib-version-parser.js +94 -0
- package/dist/plugins/packageJson.d.ts +10 -0
- package/dist/plugins/packageJson.js +66 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +19 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +6 -0
- package/package.json +26 -22
- package/dist/index.mjs +0 -1464
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import vuePlugin from 'eslint-plugin-vue';
|
|
2
|
+
import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
|
|
3
|
+
import nextcloudVuePlugin from "../plugins/nextcloud-vue/index.js";
|
|
4
|
+
import { codeStyle } from "./codeStyle.js";
|
|
5
|
+
const stylisticRules = codeStyle({
|
|
6
|
+
isLibrary: false,
|
|
7
|
+
vueIsTypescript: false,
|
|
8
|
+
}).reduce((rules, config) => ({
|
|
9
|
+
...rules,
|
|
10
|
+
...(config.rules ?? {}),
|
|
11
|
+
}), {});
|
|
12
|
+
const vueStylisticRules = Object.keys(vuePlugin.rules)
|
|
13
|
+
.filter((rule) => `@stylistic/${rule}` in stylisticRules)
|
|
14
|
+
.map((rule) => [
|
|
15
|
+
`vue/${rule}`,
|
|
16
|
+
stylisticRules[`@stylistic/${rule}`],
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* General vue related rules for both versions
|
|
20
|
+
*
|
|
21
|
+
* @param options options defining the config preset flavor
|
|
22
|
+
*/
|
|
23
|
+
export function vue(options) {
|
|
24
|
+
return [
|
|
25
|
+
...(options.vueIsTypescript
|
|
26
|
+
? [
|
|
27
|
+
{
|
|
28
|
+
languageOptions: {
|
|
29
|
+
parserOptions: {
|
|
30
|
+
parser: '@typescript-eslint/parser',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
: []),
|
|
36
|
+
{
|
|
37
|
+
files: GLOB_FILES_VUE,
|
|
38
|
+
rules: {
|
|
39
|
+
// PascalCase components names for vuejs
|
|
40
|
+
'vue/component-name-in-template-casing': [
|
|
41
|
+
'error',
|
|
42
|
+
'PascalCase',
|
|
43
|
+
],
|
|
44
|
+
// space before self-closing elements
|
|
45
|
+
'vue/html-closing-bracket-spacing': 'error',
|
|
46
|
+
// no ending html tag on a new line
|
|
47
|
+
'vue/html-closing-bracket-newline': [
|
|
48
|
+
'error',
|
|
49
|
+
{
|
|
50
|
+
multiline: 'never',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
// Enforce documentation of properties
|
|
54
|
+
'vue/require-prop-comment': options.isLibrary
|
|
55
|
+
? [
|
|
56
|
+
'error',
|
|
57
|
+
{
|
|
58
|
+
type: 'JSDoc',
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: 'off',
|
|
62
|
+
// When a prop allows Boolean and some other type, then Boolean should come first to allow short-hand properties
|
|
63
|
+
'vue/prefer-prop-type-boolean-first': 'error',
|
|
64
|
+
// Prevent useless string interpolation where not needed
|
|
65
|
+
'vue/no-useless-mustaches': 'error',
|
|
66
|
+
// If there is a default then it is not required - this is either way a bug
|
|
67
|
+
'vue/no-required-prop-with-default': 'error',
|
|
68
|
+
// Omit empty blocks
|
|
69
|
+
'vue/no-empty-component-block': 'error',
|
|
70
|
+
// Boolean properties should behave like HTML properties
|
|
71
|
+
'vue/no-boolean-default': [
|
|
72
|
+
'warn',
|
|
73
|
+
'default-false',
|
|
74
|
+
],
|
|
75
|
+
// Allow 3 attributes on the same line if singe line
|
|
76
|
+
'vue/max-attributes-per-line': [
|
|
77
|
+
'error',
|
|
78
|
+
{
|
|
79
|
+
singleline: {
|
|
80
|
+
max: 3,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
// Component names should match their export names - readability and maintainability ("where does this component come from?")
|
|
85
|
+
'vue/match-component-import-name': 'error',
|
|
86
|
+
'vue/match-component-file-name': 'error',
|
|
87
|
+
// Prevent useless v-bind like `<foo :bar="'bar'"/>`
|
|
88
|
+
'vue/no-useless-v-bind': 'error',
|
|
89
|
+
// Warn on undefined components - we need this on warning level as long as people use mixins (then we can move to error)
|
|
90
|
+
'vue/no-undef-components': [
|
|
91
|
+
'warn',
|
|
92
|
+
{
|
|
93
|
+
// Ignore the router view as this is most often globally registered
|
|
94
|
+
ignorePatterns: ['router-?view'],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
// Warn on unused refs
|
|
98
|
+
'vue/no-unused-refs': 'warn',
|
|
99
|
+
// Warn on unused props
|
|
100
|
+
'vue/no-unused-properties': 'warn',
|
|
101
|
+
},
|
|
102
|
+
name: 'nextcloud/vue/rules',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
files: GLOB_FILES_VUE,
|
|
106
|
+
rules: {
|
|
107
|
+
// same as the stylistic rules but for the <template> in Vue files
|
|
108
|
+
...Object.fromEntries(vueStylisticRules),
|
|
109
|
+
// Also enforce tabs for template
|
|
110
|
+
'vue/html-indent': [
|
|
111
|
+
'error',
|
|
112
|
+
'tab',
|
|
113
|
+
],
|
|
114
|
+
// Consistent style of props
|
|
115
|
+
'vue/new-line-between-multi-line-property': 'error',
|
|
116
|
+
// Add consistent padding between blocks
|
|
117
|
+
'vue/padding-line-between-blocks': 'error',
|
|
118
|
+
// Prefer separated static and dynamic class attributes
|
|
119
|
+
'vue/prefer-separate-static-class': 'error',
|
|
120
|
+
// For consistent layout of components
|
|
121
|
+
'vue/define-macros-order': [
|
|
122
|
+
'error', {
|
|
123
|
+
order: [
|
|
124
|
+
'defineOptions',
|
|
125
|
+
'defineModel',
|
|
126
|
+
'defineProps',
|
|
127
|
+
'defineEmits',
|
|
128
|
+
'defineSlots',
|
|
129
|
+
'defineExpose',
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
name: 'nextcloud/vue/stylistic-rules',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
files: [
|
|
138
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
139
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
140
|
+
...GLOB_FILES_VUE,
|
|
141
|
+
],
|
|
142
|
+
plugins: {
|
|
143
|
+
'@nextcloud/vue': nextcloudVuePlugin,
|
|
144
|
+
},
|
|
145
|
+
rules: {
|
|
146
|
+
'@nextcloud/vue/no-deprecated-exports': 'error',
|
|
147
|
+
'@nextcloud/vue/no-deprecated-props': 'error',
|
|
148
|
+
},
|
|
149
|
+
name: 'nextcloud/vue/migration-rules',
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
import type { Linter } from 'eslint';
|
|
6
|
+
import type { ConfigOptions } from '../types.d.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Vue2 related ESLint rules for Nextcloud
|
|
9
|
+
*
|
|
10
|
+
* @param option options defining the config preset flavor
|
|
11
|
+
*/
|
|
12
|
+
export declare function vue2(option: ConfigOptions): Linter.Config[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import vuePlugin from 'eslint-plugin-vue';
|
|
2
|
+
import { GLOB_FILES_VUE } from "../globs.js";
|
|
3
|
+
import { restrictConfigFiles } from "../utils.js";
|
|
4
|
+
import { vue } from "./vue.js";
|
|
5
|
+
/**
|
|
6
|
+
* Vue2 related ESLint rules for Nextcloud
|
|
7
|
+
*
|
|
8
|
+
* @param option options defining the config preset flavor
|
|
9
|
+
*/
|
|
10
|
+
export function vue2(option) {
|
|
11
|
+
return [
|
|
12
|
+
...restrictConfigFiles(vuePlugin.configs['flat/vue2-recommended'], GLOB_FILES_VUE),
|
|
13
|
+
...vue(option),
|
|
14
|
+
{
|
|
15
|
+
rules: {
|
|
16
|
+
// custom event naming convention
|
|
17
|
+
'vue/custom-event-name-casing': [
|
|
18
|
+
'error',
|
|
19
|
+
'kebab-case',
|
|
20
|
+
{
|
|
21
|
+
// allows custom xxxx:xxx events formats
|
|
22
|
+
ignores: ['/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
files: GLOB_FILES_VUE,
|
|
27
|
+
name: 'nextcloud/vue2/rules',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
import type { Linter } from 'eslint';
|
|
6
|
+
import type { ConfigOptions } from '../types.d.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Vue3 related ESLint rules for Nextcloud
|
|
9
|
+
*
|
|
10
|
+
* @param options options defining the config preset flavor
|
|
11
|
+
*/
|
|
12
|
+
export declare function vue3(options: ConfigOptions): Linter.Config[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import vuePlugin from 'eslint-plugin-vue';
|
|
2
|
+
import { GLOB_FILES_VUE } from "../globs.js";
|
|
3
|
+
import { restrictConfigFiles } from "../utils.js";
|
|
4
|
+
import { vue } from "./vue.js";
|
|
5
|
+
/**
|
|
6
|
+
* Vue3 related ESLint rules for Nextcloud
|
|
7
|
+
*
|
|
8
|
+
* @param options options defining the config preset flavor
|
|
9
|
+
*/
|
|
10
|
+
export function vue3(options) {
|
|
11
|
+
return [
|
|
12
|
+
...restrictConfigFiles(vuePlugin.configs['flat/recommended'], GLOB_FILES_VUE),
|
|
13
|
+
...vue(options),
|
|
14
|
+
// Vue3 specific overrides
|
|
15
|
+
{
|
|
16
|
+
files: GLOB_FILES_VUE,
|
|
17
|
+
rules: {
|
|
18
|
+
// Deprecated thus we should not use it
|
|
19
|
+
'vue/no-deprecated-delete-set': 'error',
|
|
20
|
+
// When using script-setup the modern approach should be used
|
|
21
|
+
'vue/prefer-define-options': 'error',
|
|
22
|
+
},
|
|
23
|
+
name: 'nextcloud/vue3/rules',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}
|
package/dist/globs.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
/** Glob pattern for test files (specs) */
|
|
6
|
+
export declare const GLOB_FILES_TESTING: string[];
|
|
7
|
+
/** Glob pattern for Typescript files */
|
|
8
|
+
export declare const GLOB_FILES_TYPESCRIPT: string[];
|
|
9
|
+
/** Glob pattern for Typescript declaration files */
|
|
10
|
+
export declare const GLOB_FILES_TYPESCRIPT_DECLARATIONS: string[];
|
|
11
|
+
/** Glob pattern for Javascript files */
|
|
12
|
+
export declare const GLOB_FILES_JAVASCRIPT: string[];
|
|
13
|
+
/** Glob pattern for JSON files */
|
|
14
|
+
export declare const GLOB_FILES_JSON: string[];
|
|
15
|
+
/** Glob pattern for JSONC files */
|
|
16
|
+
export declare const GLOB_FILES_JSONC: string[];
|
|
17
|
+
/** Glob pattern for Microsoft JSON files which use a slightly different JSONC implementation */
|
|
18
|
+
export declare const GLOB_FILES_MS_JSON: string[];
|
|
19
|
+
/** Glob pattern for Vue.JS files */
|
|
20
|
+
export declare const GLOB_FILES_VUE: string[];
|
package/dist/globs.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
/** Glob pattern for test files (specs) */
|
|
6
|
+
export const GLOB_FILES_TESTING = [
|
|
7
|
+
'**/*.test.*',
|
|
8
|
+
'**/*.spec.*',
|
|
9
|
+
'**/*.cy.*',
|
|
10
|
+
'**/test',
|
|
11
|
+
'**/tests',
|
|
12
|
+
];
|
|
13
|
+
/** Glob pattern for Typescript files */
|
|
14
|
+
export const GLOB_FILES_TYPESCRIPT = [
|
|
15
|
+
'**/*.ts',
|
|
16
|
+
'**/*.mts',
|
|
17
|
+
'**/*.cts',
|
|
18
|
+
'**/*.tsx',
|
|
19
|
+
];
|
|
20
|
+
/** Glob pattern for Typescript declaration files */
|
|
21
|
+
export const GLOB_FILES_TYPESCRIPT_DECLARATIONS = ['**/*.d.ts'];
|
|
22
|
+
/** Glob pattern for Javascript files */
|
|
23
|
+
export const GLOB_FILES_JAVASCRIPT = [
|
|
24
|
+
'**/*.js',
|
|
25
|
+
'**/*.cjs',
|
|
26
|
+
'**/*.mjs',
|
|
27
|
+
'**/*.jsx',
|
|
28
|
+
];
|
|
29
|
+
/** Glob pattern for JSON files */
|
|
30
|
+
export const GLOB_FILES_JSON = ['**/*.json'];
|
|
31
|
+
/** Glob pattern for JSONC files */
|
|
32
|
+
export const GLOB_FILES_JSONC = ['**/*.jsonc'];
|
|
33
|
+
/** Glob pattern for Microsoft JSON files which use a slightly different JSONC implementation */
|
|
34
|
+
export const GLOB_FILES_MS_JSON = [
|
|
35
|
+
'**/tsconfig.json',
|
|
36
|
+
'.vscode/*.json',
|
|
37
|
+
];
|
|
38
|
+
/** Glob pattern for Vue.JS files */
|
|
39
|
+
export const GLOB_FILES_VUE = ['**/*.vue'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Nextcloud shared configuration for projects using Vue
|
|
23
|
-
*/
|
|
24
|
-
export declare const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
export declare const recommendedVue2Javascript: (Linter.Config<Linter.RulesRecord> | Linter.BaseConfig<Linter.RulesRecord, Linter.RulesRecord>)[];
|
|
30
|
-
|
|
31
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Nextcloud shared configuration for projects using Vue 2 with Javascript <script> blocks
|
|
3
|
+
*/
|
|
4
|
+
export declare const recommendedVue2Javascript: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
5
|
+
/**
|
|
6
|
+
* Nextcloud shared configuration for projects using Vue 2 with Typescript <script> blocks
|
|
7
|
+
*/
|
|
8
|
+
export declare const recommendedVue2: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
9
|
+
/**
|
|
10
|
+
* Nextcloud shared configuration for projects using Vue 3 with Javascript <script> blocks
|
|
11
|
+
*/
|
|
12
|
+
export declare const recommendedJavascript: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
13
|
+
/**
|
|
14
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
15
|
+
*/
|
|
16
|
+
export declare const recommended: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
17
|
+
/**
|
|
18
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
19
|
+
*/
|
|
20
|
+
export declare const recommendedLibrary: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
21
|
+
/**
|
|
22
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
23
|
+
*/
|
|
24
|
+
export declare const recommendedVue2Library: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("eslint").Linter.BaseConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>)[];
|
|
25
|
+
export { default as packageJsonPlugin } from './plugins/packageJson.ts';
|
|
26
|
+
export { default as nextcloudPlugin } from './plugins/nextcloud/index.ts';
|
|
27
|
+
export { default as l10nPlugin } from './plugins/l10n/index.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { codeStyle } from "./configs/codeStyle.js";
|
|
2
|
+
import { documentation } from "./configs/documentation.js";
|
|
3
|
+
import { filesystem } from "./configs/filesystem.js";
|
|
4
|
+
import { imports } from "./configs/imports.js";
|
|
5
|
+
import { javascript } from "./configs/javascript.js";
|
|
6
|
+
import { json } from "./configs/json.js";
|
|
7
|
+
import { node } from "./configs/node.js";
|
|
8
|
+
import { typescript } from "./configs/typescript.js";
|
|
9
|
+
import { vue2 } from "./configs/vue2.js";
|
|
10
|
+
import { vue3 } from "./configs/vue3.js";
|
|
11
|
+
/**
|
|
12
|
+
* Nextcloud shared configuration for projects using Vue 2 with Javascript <script> blocks
|
|
13
|
+
*/
|
|
14
|
+
export const recommendedVue2Javascript = createConfig({
|
|
15
|
+
isLibrary: false,
|
|
16
|
+
vue2: true,
|
|
17
|
+
vueIsTypescript: false,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Nextcloud shared configuration for projects using Vue 2 with Typescript <script> blocks
|
|
21
|
+
*/
|
|
22
|
+
export const recommendedVue2 = createConfig({
|
|
23
|
+
isLibrary: false,
|
|
24
|
+
vue2: true,
|
|
25
|
+
vueIsTypescript: true,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Nextcloud shared configuration for projects using Vue 3 with Javascript <script> blocks
|
|
29
|
+
*/
|
|
30
|
+
export const recommendedJavascript = createConfig({
|
|
31
|
+
isLibrary: false,
|
|
32
|
+
vueIsTypescript: false,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
36
|
+
*/
|
|
37
|
+
export const recommended = createConfig({
|
|
38
|
+
isLibrary: false,
|
|
39
|
+
vueIsTypescript: true,
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
43
|
+
*/
|
|
44
|
+
export const recommendedLibrary = createConfig({
|
|
45
|
+
isLibrary: true,
|
|
46
|
+
vueIsTypescript: true,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
|
|
50
|
+
*/
|
|
51
|
+
export const recommendedVue2Library = createConfig({
|
|
52
|
+
isLibrary: true,
|
|
53
|
+
vue2: true,
|
|
54
|
+
vueIsTypescript: true,
|
|
55
|
+
});
|
|
56
|
+
export { default as packageJsonPlugin } from "./plugins/packageJson.js";
|
|
57
|
+
export { default as nextcloudPlugin } from "./plugins/nextcloud/index.js";
|
|
58
|
+
export { default as l10nPlugin } from "./plugins/l10n/index.js";
|
|
59
|
+
/**
|
|
60
|
+
* Generate a configuration based on given options
|
|
61
|
+
*
|
|
62
|
+
* @param options - Configuration options
|
|
63
|
+
*/
|
|
64
|
+
function createConfig(options) {
|
|
65
|
+
return [
|
|
66
|
+
...filesystem,
|
|
67
|
+
...javascript(options),
|
|
68
|
+
...json,
|
|
69
|
+
...node,
|
|
70
|
+
...typescript(options),
|
|
71
|
+
...(options.vue2
|
|
72
|
+
? vue2(options)
|
|
73
|
+
: vue3(options)),
|
|
74
|
+
...documentation(options),
|
|
75
|
+
...imports(options),
|
|
76
|
+
...codeStyle(options),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
import type { ESLint } from 'eslint';
|
|
6
|
+
/**
|
|
7
|
+
* ESLint plugin to enforce consistent translations
|
|
8
|
+
*/
|
|
9
|
+
declare const Plugin: ESLint.Plugin;
|
|
10
|
+
export default Plugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { packageVersion } from "../../version.js";
|
|
2
|
+
import RuleEllipsis from "./rules/enforce-ellipsis.js";
|
|
3
|
+
import RuleNonBreakingSpace from "./rules/non-breaking-space.js";
|
|
4
|
+
/**
|
|
5
|
+
* ESLint plugin to enforce consistent translations
|
|
6
|
+
*/
|
|
7
|
+
const Plugin = {
|
|
8
|
+
meta: {
|
|
9
|
+
name: '@nextcloud/l10n-plugin',
|
|
10
|
+
version: packageVersion,
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
'non-breaking-space': RuleNonBreakingSpace,
|
|
14
|
+
'enforce-ellipsis': RuleEllipsis,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default Plugin;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const defineRule = (r) => r;
|
|
2
|
+
export default defineRule({
|
|
3
|
+
meta: {
|
|
4
|
+
fixable: 'code',
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
schema: [],
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Enforce consistent usageof ellipsis instead of tripple dots',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
create(context) {
|
|
12
|
+
return {
|
|
13
|
+
Literal(node) {
|
|
14
|
+
if (typeof node.value !== 'string'
|
|
15
|
+
|| node.parent.type !== 'CallExpression'
|
|
16
|
+
|| node.parent.callee.type !== 'Identifier'
|
|
17
|
+
|| node.parent.callee.name !== 't') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (node.raw?.match(/(?<=[^.])\.\.\.(?!\.)/)) {
|
|
21
|
+
context.report({
|
|
22
|
+
node,
|
|
23
|
+
message: 'Strings should ellipsis instead of triple dots',
|
|
24
|
+
fix(fixer) {
|
|
25
|
+
return fixer.replaceText(node, node.raw.replaceAll(/(?<=[^.])\.\.\.(?!\.)/g, '…'));
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const defineRule = (r) => r;
|
|
2
|
+
export default defineRule({
|
|
3
|
+
meta: {
|
|
4
|
+
fixable: 'code',
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
schema: [],
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Enforce non-breaking spaces before ellipsis',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
create(context) {
|
|
12
|
+
return {
|
|
13
|
+
Literal(node) {
|
|
14
|
+
if (typeof node.value !== 'string') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const matches = node.value.match(/(\s+)…/);
|
|
18
|
+
if (matches && matches[1] !== ' ') {
|
|
19
|
+
context.report({
|
|
20
|
+
node,
|
|
21
|
+
message: 'Ellipsis must be preceded by non-breaking spaces',
|
|
22
|
+
fix(fixer) {
|
|
23
|
+
return fixer.replaceText(node, node.raw.replaceAll(/\s+…/g, ' …'));
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|