@nextcloud/eslint-config 8.4.2 → 9.0.0-rc.1
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 +44 -0
- package/README.md +151 -25
- package/dist/configs/codeStyle.d.ts +13 -0
- package/dist/configs/codeStyle.js +178 -0
- package/dist/configs/documentation.d.ts +12 -0
- package/dist/configs/documentation.js +84 -0
- package/dist/configs/filesystem.d.ts +9 -0
- package/dist/configs/filesystem.js +18 -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 +53 -0
- package/dist/configs/vue.d.ts +12 -0
- package/dist/configs/vue.js +134 -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 +24 -0
- package/dist/globs.d.ts +18 -0
- package/dist/globs.js +37 -0
- package/dist/index.d.ts +27 -0
- 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 +8 -0
- package/dist/plugins/nextcloud-vue/index.js +9 -0
- package/dist/plugins/nextcloud-vue/rules/index.d.ts +6 -0
- package/dist/plugins/nextcloud-vue/rules/index.js +4 -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/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 +53 -53
- package/.git-blame-ignore-revs +0 -7
- package/LICENSES/AGPL-3.0-or-later.txt +0 -235
- package/LICENSES/CC0-1.0.txt +0 -121
- package/LICENSES/MIT.txt +0 -9
- package/REUSE.toml +0 -12
- package/index.js +0 -25
- package/parts/base.js +0 -117
- package/parts/typescript.js +0 -49
- package/parts/vue.js +0 -45
- package/parts/vue3.js +0 -43
- package/typescript.js +0 -45
- package/vue3.js +0 -45
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,49 @@
|
|
|
4
4
|
-->
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## [v9.0.0](https://github.com/nextcloud-libraries/eslint-config/tree/v9.0.0) (2025)
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
This package now is using ESLint v9 and requires ESLint flat configurations.
|
|
11
|
+
Please refer to the README on how to adjust your configuration for flat config.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
* feat: new modular config for (and with) ESLint v9 support [#887](https://github.com/nextcloud-libraries/eslint-config/pull/887)
|
|
15
|
+
* feat: merge plugin repository [#899](https://github.com/nextcloud-libraries/eslint-config/pull/899)
|
|
16
|
+
* feat: enforce non-breaking spaces before ellipsis for translations [\#948](https://github.com/nextcloud-libraries/eslint-config/pull/948)
|
|
17
|
+
* feat: add special config for libraries [\#949](https://github.com/nextcloud-libraries/eslint-config/pull/949)
|
|
18
|
+
* feat: add import and export rules [\#981](https://github.com/nextcloud-libraries/eslint-config/pull/981)
|
|
19
|
+
* feat: introduce @nextcloud/vue eslint plugin [\#939](https://github.com/nextcloud-libraries/eslint-config/pull/939)
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
* fix(codestyle): do not require splitting chains [\#951](https://github.com/nextcloud-libraries/eslint-config/pull/951)
|
|
23
|
+
* fix(codestyle): adjust empty lines style [\#952](https://github.com/nextcloud-libraries/eslint-config/pull/952)
|
|
24
|
+
* fix(codestyle): Enforce no space before function parenthesis [#901](https://github.com/nextcloud-libraries/eslint-config/pull/901)
|
|
25
|
+
* fix(codeStyle): Adjust `stylistic` rules config [#914](https://github.com/nextcloud-libraries/eslint-config/pull/914)
|
|
26
|
+
* fix(codeStyle): allow single line arrays [\#997](https://github.com/nextcloud-libraries/eslint-config/pull/997)
|
|
27
|
+
* fix(codeStyle): allow devs write small objects in one line [\#996](https://github.com/nextcloud-libraries/eslint-config/pull/996)
|
|
28
|
+
* fix(globs): properly ignore test files [\#974](https://github.com/nextcloud-libraries/eslint-config/pull/974)
|
|
29
|
+
* fix(imports): do not mix externals and internals [\#1000](https://github.com/nextcloud-libraries/eslint-config/pull/1000)
|
|
30
|
+
* fix(javascript): allow using functions before they are defined [\#970](https://github.com/nextcloud-libraries/eslint-config/pull/970)
|
|
31
|
+
* fix(javascript): add missing `appName` and `appVersion` global + fix access [\#972](https://github.com/nextcloud-libraries/eslint-config/pull/972)
|
|
32
|
+
* fix(typescript): allow to use function before definition [\#950](https://github.com/nextcloud-libraries/eslint-config/pull/950)
|
|
33
|
+
* fix(typescript): remove `@typescript-eslint/no-shadow` [\#993](https://github.com/nextcloud-libraries/eslint-config/pull/993)
|
|
34
|
+
* fix(typescript): enforce `import type` for type only imports [\#977](https://github.com/nextcloud-libraries/eslint-config/pull/977)
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
* Add SPDX header [#802](https://github.com/nextcloud-libraries/eslint-config/pull/802)
|
|
38
|
+
* Updated development dependencies
|
|
39
|
+
* refactor(json): drop now unneeded `@ts-expect-error` [#915](https://github.com/nextcloud-libraries/eslint-config/pull/915)
|
|
40
|
+
* chore: do not bundle config but just use Typescript [#967](https://github.com/nextcloud-libraries/eslint-config/pull/967)
|
|
41
|
+
* chore: require node ^20.19 [\#982](https://github.com/nextcloud-libraries/eslint-config/pull/982)
|
|
42
|
+
* Updated `@eslint/json` to 0.12.0
|
|
43
|
+
* Updated `@stylistic/eslint-plugin` 4.2.0
|
|
44
|
+
* Updated `eslint-plugin-jsdoc` to 50.6.11
|
|
45
|
+
* Updated `eslint-plugin-vue` to 10.0.0
|
|
46
|
+
* Updated `fast-xml-parser` to 5.2.1
|
|
47
|
+
* Updated `sort-package-json` to 3.0.0
|
|
48
|
+
* Updated `typescript-eslint` to 8.31.0
|
|
49
|
+
|
|
7
50
|
## [v8.4.2](https://github.com/nextcloud-libraries/eslint-config/tree/v8.4.2) (2025-02-16)
|
|
8
51
|
### Fixed
|
|
9
52
|
* fix(typescript): do not require returns type in jsdoc by @ShGKme in https://github.com/nextcloud-libraries/eslint-config/pull/857
|
|
@@ -14,6 +57,7 @@
|
|
|
14
57
|
* enh(git): ignore formatting commits in git blame by @max-nextcloud in https://github.com/nextcloud-libraries/eslint-config/pull/854
|
|
15
58
|
|
|
16
59
|
## [v8.4.1](https://github.com/nextcloud-libraries/eslint-config/tree/v8.4.1) (2024-05-16)
|
|
60
|
+
|
|
17
61
|
[Full Changelog](https://github.com/nextcloud-libraries/eslint-config/compare/v8.4.0...v8.4.1)
|
|
18
62
|
|
|
19
63
|
### Fixes
|
package/README.md
CHANGED
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
[](https://dependabot.com)
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
This is a package containing the unified global eslint config used by all nextcloud apps.
|
|
13
|
+
This is a package containing the unified global eslint config used by all nextcloud apps and libraries.
|
|
14
14
|
It contains the necessary dependencies and peerDependencies so that other apps cannot update if this config does not support it.
|
|
15
15
|
Please always use dependabot to update your apps, OR pay attention to the peer dependencies error messages!
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
## Installation
|
|
19
18
|
|
|
20
19
|
```bash
|
|
@@ -23,43 +22,170 @@ npm install @nextcloud/eslint-config --save-dev
|
|
|
23
22
|
|
|
24
23
|
## Usage
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
> [!NOTE]
|
|
26
|
+
> Since version 9 this package depends on ESLint 9, which uses the new flat config system.
|
|
27
|
+
|
|
28
|
+
This package provides some predefined configurations you can choose from.
|
|
29
|
+
For the recommended setup add a file `eslint.config.js` in the root directory of your app repository with the following content:
|
|
27
30
|
|
|
28
31
|
```js
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
import { recommended } from '@nextcloud/eslint-config'
|
|
33
|
+
|
|
34
|
+
export default [
|
|
35
|
+
...recommended,
|
|
36
|
+
]
|
|
34
37
|
```
|
|
35
38
|
|
|
36
|
-
###
|
|
39
|
+
### Available configurations
|
|
40
|
+
|
|
41
|
+
Instead of the `recommended` configuration this package also provides some alternatives, depending on your app setup you can also choose:
|
|
42
|
+
|
|
43
|
+
* `recommended`
|
|
44
|
+
* General rules including code style
|
|
45
|
+
* Support for Typescript
|
|
46
|
+
* Support for Vue **3**
|
|
47
|
+
* Support Vue files with Typescript syntax (the script within `.vue` files will be handled as Typescript).
|
|
48
|
+
* `recommendedJavascript`
|
|
49
|
+
* Same as `recommended` but Vue files (the script part) will be handled as Javascript.
|
|
50
|
+
* `recommendedVue2`
|
|
51
|
+
* Same as `recommended` but Vue files are considered in Vue 2 syntax.
|
|
52
|
+
* `recommendedVue2Javascript`
|
|
53
|
+
* Same as `recommended` but Vue files are considered in Vue 2 syntax and the script part will be handled as Javascript instead of Typescript.
|
|
37
54
|
|
|
38
|
-
|
|
55
|
+
#### Configurations for Nextcloud libraries
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
For libraries some of the presets make no sense, like checking Nextcloud deprecated API.
|
|
58
|
+
But on the otherhand some rules should be enforced, like documenting all properties.
|
|
59
|
+
So for libraries use following configurations:
|
|
41
60
|
|
|
61
|
+
* `recommendedLibrary`
|
|
62
|
+
* `recommendedVue2Library`
|
|
63
|
+
|
|
64
|
+
### Bundled plugins
|
|
65
|
+
|
|
66
|
+
This configuration also provides some bundled plugins with new rules, those options are already included in the recommended configurations.
|
|
67
|
+
|
|
68
|
+
It is possible to override the recommended configurations:
|
|
42
69
|
```js
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
// eslint.config.js
|
|
71
|
+
import { recommended } from '@nextcloud/eslint-config'
|
|
72
|
+
export default [
|
|
73
|
+
...recommended,
|
|
74
|
+
{
|
|
75
|
+
files: ['**/*.js'],
|
|
76
|
+
rules: {
|
|
77
|
+
// Make deprecations error instead of warning level
|
|
78
|
+
'@nextcloud/no-deprecations': ['error'],
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
48
82
|
```
|
|
49
83
|
|
|
50
|
-
|
|
84
|
+
You can even use the plugins without using the Nextcloud ESLint config:
|
|
85
|
+
```js
|
|
86
|
+
// eslint.config.js
|
|
87
|
+
import { nextcloudPlugin } from '@nextcloud/eslint-config'
|
|
88
|
+
export default [
|
|
89
|
+
{
|
|
90
|
+
files: ['**/*.js'],
|
|
91
|
+
plugins: {
|
|
92
|
+
'@nextcloud': nextcloudPlugin,
|
|
93
|
+
},
|
|
94
|
+
rules: {
|
|
95
|
+
'@nextcloud/no-removed-apis': ['error', { targetVersion: '29.0.0' }],
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### `package-json` plugin
|
|
102
|
+
Rules:
|
|
103
|
+
- `sort-package-json`
|
|
104
|
+
- Ensures the `package.json` is sorted in consistent order
|
|
105
|
+
- Included as `error` level in recommended configurations
|
|
106
|
+
|
|
107
|
+
#### `@nextcloud` plugin
|
|
108
|
+
Rules:
|
|
109
|
+
- `no-deprecations`
|
|
110
|
+
- Report usage of deprecated Nextcloud API
|
|
111
|
+
- Included as `warn` level in recommended configuration
|
|
112
|
+
- Available options
|
|
113
|
+
```ts
|
|
114
|
+
{
|
|
115
|
+
/**
|
|
116
|
+
* Limit deprecated API to specified Nextcloud version
|
|
117
|
+
* @example '29.0.0'
|
|
118
|
+
* @default ''
|
|
119
|
+
*/
|
|
120
|
+
targetVersion?: string
|
|
121
|
+
/**
|
|
122
|
+
* Try to find appinfo.xml to detect targetVersion
|
|
123
|
+
* @default true
|
|
124
|
+
*/
|
|
125
|
+
parseAppInfo?: boolean
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
- `no-removed-apis`
|
|
129
|
+
- Report usage of removed Nextcloud API
|
|
130
|
+
- Included as `error` level in recommended configuration
|
|
131
|
+
- Available options
|
|
132
|
+
```ts
|
|
133
|
+
{
|
|
134
|
+
/**
|
|
135
|
+
* Limit removed API to specified Nextcloud version
|
|
136
|
+
* @example '29.0.0'
|
|
137
|
+
* @default ''
|
|
138
|
+
*/
|
|
139
|
+
targetVersion?: string
|
|
140
|
+
/**
|
|
141
|
+
* Try to find appinfo.xml to detect targetVersion
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
parseAppInfo?: boolean
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### `@nextcloud-l10n`
|
|
149
|
+
```ts
|
|
150
|
+
import { l10nPlugin } from '@nextcloud/eslint-config'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Rules:
|
|
154
|
+
- `enforce-ellipsis`
|
|
155
|
+
- Enforce consistent usageof ellipsis instead of tripple dots
|
|
156
|
+
- Included as `error` level in recommended configuration
|
|
157
|
+
- `non-breaking-space`
|
|
158
|
+
- Enforce non-breaking spaces before ellipsis
|
|
159
|
+
- Included as `error` level in recommended configuration
|
|
51
160
|
|
|
52
|
-
|
|
53
|
-
|
|
161
|
+
### Adding custom overrides
|
|
162
|
+
|
|
163
|
+
Sometimes additional rules need to be added for individual projects,
|
|
164
|
+
and while we do not recommend to override Nextcloud rules for code style (it should be consistent across all Nextcloud projects!),
|
|
165
|
+
it is possible to add such custom rules.
|
|
166
|
+
|
|
167
|
+
For example to enforce chains to be on separate lines:
|
|
168
|
+
|
|
169
|
+
```diff
|
|
170
|
+
- const a = foo().then((a) => a.b).catch((e) => e.c)
|
|
171
|
+
+ const a = foo()
|
|
172
|
+
+ .then((a) => a.b)
|
|
173
|
+
+ .catch((e) => e.c)
|
|
174
|
+
```
|
|
54
175
|
|
|
55
|
-
|
|
176
|
+
Adjust your `eslint.config.js` like this:
|
|
56
177
|
|
|
57
178
|
```js
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
179
|
+
import { recommended } from '@nextcloud/eslint-config'
|
|
180
|
+
|
|
181
|
+
export default [
|
|
182
|
+
...recommended,
|
|
183
|
+
{
|
|
184
|
+
rules: {
|
|
185
|
+
'@stylistic/newline-per-chained-call': ['error'],
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
]
|
|
63
189
|
```
|
|
64
190
|
|
|
65
191
|
## Release new version
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
* Config factory for general code style related rules
|
|
9
|
+
* See also: https://docs.nextcloud.com/server/latest/developer_manual/getting_started/coding_standards/javascript.html#code-style
|
|
10
|
+
*
|
|
11
|
+
* @param options options defining the config preset flavor
|
|
12
|
+
*/
|
|
13
|
+
export declare function codeStyle(options: ConfigOptions): (Linter.Config | Linter.BaseConfig)[];
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
2
|
+
import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
|
|
3
|
+
import l10nPlugin from "../plugins/l10n/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Config factory for general code style related rules
|
|
6
|
+
* See also: https://docs.nextcloud.com/server/latest/developer_manual/getting_started/coding_standards/javascript.html#code-style
|
|
7
|
+
*
|
|
8
|
+
* @param options options defining the config preset flavor
|
|
9
|
+
*/
|
|
10
|
+
export function codeStyle(options) {
|
|
11
|
+
return [
|
|
12
|
+
// Nextcloud code style
|
|
13
|
+
{
|
|
14
|
+
name: '@stylistic/configs/recommended',
|
|
15
|
+
files: [
|
|
16
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
17
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
18
|
+
...GLOB_FILES_VUE,
|
|
19
|
+
],
|
|
20
|
+
...stylistic.configs.customize({
|
|
21
|
+
indent: 'tab',
|
|
22
|
+
semi: false,
|
|
23
|
+
quotes: 'single',
|
|
24
|
+
quoteProps: 'as-needed',
|
|
25
|
+
commaDangle: 'always-multiline',
|
|
26
|
+
arrowParens: true,
|
|
27
|
+
braceStyle: '1tbs',
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'nextcloud/stylistic/rules',
|
|
32
|
+
files: [
|
|
33
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
34
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
35
|
+
...GLOB_FILES_VUE,
|
|
36
|
+
],
|
|
37
|
+
rules: {
|
|
38
|
+
// Overrides for the stylistic recommended rules
|
|
39
|
+
// Tabs should only be used for indention
|
|
40
|
+
'@stylistic/no-tabs': [
|
|
41
|
+
'error',
|
|
42
|
+
{ allowIndentationTabs: true },
|
|
43
|
+
],
|
|
44
|
+
// allow spaces after tabs for alignment
|
|
45
|
+
'@stylistic/no-mixed-spaces-and-tabs': [
|
|
46
|
+
'error',
|
|
47
|
+
'smart-tabs',
|
|
48
|
+
],
|
|
49
|
+
// allow backticks for strings that contain single quotes
|
|
50
|
+
'@stylistic/quotes': [
|
|
51
|
+
'error',
|
|
52
|
+
'single',
|
|
53
|
+
{
|
|
54
|
+
allowTemplateLiterals: false,
|
|
55
|
+
avoidEscape: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
// Not included in stylistic preset but set by us:
|
|
59
|
+
// Enforce camelCase but allow legacy webpack variables
|
|
60
|
+
camelcase: [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
allow: ['^__webpack_'],
|
|
64
|
+
properties: 'never',
|
|
65
|
+
ignoreGlobals: true,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
// Make sure to use object shorthand properties
|
|
69
|
+
'object-shorthand': [
|
|
70
|
+
'error',
|
|
71
|
+
'properties',
|
|
72
|
+
{ avoidQuotes: true },
|
|
73
|
+
],
|
|
74
|
+
// Enforce new lines after [ and before ] if there are multiline entries or more than 1 item in the array (better git diff)
|
|
75
|
+
'@stylistic/array-bracket-newline': [
|
|
76
|
+
'error',
|
|
77
|
+
{
|
|
78
|
+
multiline: true,
|
|
79
|
+
minItems: null, // disable
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
// Enforce new lines between array elements (better git diff) but allow to have single line arrays
|
|
83
|
+
'@stylistic/array-element-newline': ['error', 'consistent'],
|
|
84
|
+
// Same for objects as for arrays
|
|
85
|
+
'@stylistic/object-curly-newline': [
|
|
86
|
+
'error',
|
|
87
|
+
{
|
|
88
|
+
consistent: true,
|
|
89
|
+
multiline: true,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
'@stylistic/object-property-newline': [
|
|
93
|
+
'error',
|
|
94
|
+
{ allowAllPropertiesOnSameLine: true },
|
|
95
|
+
],
|
|
96
|
+
// No space between function name and parenthesis. Enforce fn() instead of fn ()
|
|
97
|
+
'@stylistic/function-call-spacing': [
|
|
98
|
+
'error',
|
|
99
|
+
'never',
|
|
100
|
+
],
|
|
101
|
+
// No space between function name and parenthesis on definition. Enforce `function foo()` instead of `function foo ()`.
|
|
102
|
+
'@stylistic/space-before-function-paren': [
|
|
103
|
+
'error',
|
|
104
|
+
{
|
|
105
|
+
// good: `function() {}` bad: `function () {}`
|
|
106
|
+
anonymous: 'never',
|
|
107
|
+
// good `function foo() {}` bad: `function foo () {}`
|
|
108
|
+
named: 'never',
|
|
109
|
+
// consistency for arrow functions regardless of async or sync:
|
|
110
|
+
// good `async () => {}` bad `async() => {}`
|
|
111
|
+
asyncArrow: 'always',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
// Enforce consistent newlines in function parameters, if one parameter is separated by newline, than all should
|
|
115
|
+
'@stylistic/function-call-argument-newline': [
|
|
116
|
+
'error',
|
|
117
|
+
'consistent',
|
|
118
|
+
],
|
|
119
|
+
// If parameters are separated by newlines, then the first one should also be separated by a newline from the parenthesis
|
|
120
|
+
'@stylistic/function-paren-newline': [
|
|
121
|
+
'error',
|
|
122
|
+
'multiline',
|
|
123
|
+
],
|
|
124
|
+
// Generator functions should have the * on the function keyword as this defines the type of function. "function* generator()"
|
|
125
|
+
'@stylistic/generator-star-spacing': [
|
|
126
|
+
'error',
|
|
127
|
+
'after',
|
|
128
|
+
],
|
|
129
|
+
// Arrow functions with implicit return should not have line breaks
|
|
130
|
+
// TODO: Discuss
|
|
131
|
+
'@stylistic/implicit-arrow-linebreak': [
|
|
132
|
+
'error',
|
|
133
|
+
'beside',
|
|
134
|
+
],
|
|
135
|
+
// Prevent issues with different OS by enforcing single line feed for new lien
|
|
136
|
+
'@stylistic/linebreak-style': [
|
|
137
|
+
'error',
|
|
138
|
+
'unix',
|
|
139
|
+
],
|
|
140
|
+
// No useless semicolons
|
|
141
|
+
'@stylistic/no-extra-semi': ['error'],
|
|
142
|
+
'no-useless-concat': 'error',
|
|
143
|
+
// Prefer { ...foo } over Object.assign({}, foo)
|
|
144
|
+
'prefer-object-spread': 'warn',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'nextcloud/stylistic/ts-rules',
|
|
149
|
+
files: [
|
|
150
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
151
|
+
...(options.vueIsTypescript ? GLOB_FILES_VUE : []),
|
|
152
|
+
],
|
|
153
|
+
rules: {
|
|
154
|
+
// consistent spacing for types
|
|
155
|
+
'@stylistic/type-annotation-spacing': 'error',
|
|
156
|
+
// consistent spacing for generics
|
|
157
|
+
'@stylistic/type-generic-spacing': 'error',
|
|
158
|
+
'@stylistic/type-named-tuple-spacing': 'error',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'nextcloud/stylistic/l10n',
|
|
163
|
+
files: [
|
|
164
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
165
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
166
|
+
...GLOB_FILES_VUE,
|
|
167
|
+
],
|
|
168
|
+
plugins: {
|
|
169
|
+
'@nextcloud-l10n': l10nPlugin,
|
|
170
|
+
},
|
|
171
|
+
// Enforce that translations use ellipsis instead of tripple dots
|
|
172
|
+
rules: {
|
|
173
|
+
'@nextcloud-l10n/non-breaking-space': 'error',
|
|
174
|
+
'@nextcloud-l10n/enforce-ellipsis': 'error',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
}
|
|
@@ -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
|
+
* Config factory for code documentation related rules (JSDoc)
|
|
9
|
+
*
|
|
10
|
+
* @param options options defining the config preset flavor
|
|
11
|
+
*/
|
|
12
|
+
export declare function documentation(options: ConfigOptions): Linter.Config[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import jsdocPlugin from 'eslint-plugin-jsdoc';
|
|
2
|
+
import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TESTING, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
|
|
3
|
+
/**
|
|
4
|
+
* Config factory for code documentation related rules (JSDoc)
|
|
5
|
+
*
|
|
6
|
+
* @param options options defining the config preset flavor
|
|
7
|
+
*/
|
|
8
|
+
export function documentation(options) {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
files: [
|
|
12
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
13
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
14
|
+
...GLOB_FILES_VUE,
|
|
15
|
+
],
|
|
16
|
+
plugins: {
|
|
17
|
+
jsdoc: jsdocPlugin,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
...jsdocPlugin.configs['flat/recommended-typescript-flavor'],
|
|
22
|
+
files: [
|
|
23
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
24
|
+
...(options.vueIsTypescript ? [] : GLOB_FILES_VUE),
|
|
25
|
+
],
|
|
26
|
+
settings: {
|
|
27
|
+
jsdoc: {
|
|
28
|
+
mode: 'permissive',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
ignores: GLOB_FILES_TESTING,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
...jsdocPlugin.configs['flat/recommended-typescript'],
|
|
35
|
+
files: [
|
|
36
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
37
|
+
...(options.vueIsTypescript ? GLOB_FILES_VUE : []),
|
|
38
|
+
],
|
|
39
|
+
ignores: GLOB_FILES_TESTING,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
rules: {
|
|
43
|
+
// Force proper documentation
|
|
44
|
+
'jsdoc/check-tag-names': 'error',
|
|
45
|
+
// But ignore return values
|
|
46
|
+
'jsdoc/require-returns': 'off',
|
|
47
|
+
'jsdoc/require-returns-description': 'off',
|
|
48
|
+
// Allow one empty line in jsdoc blocks
|
|
49
|
+
'jsdoc/tag-lines': [
|
|
50
|
+
'warn',
|
|
51
|
+
'any',
|
|
52
|
+
{ startLines: 1 },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
files: [
|
|
56
|
+
...GLOB_FILES_JAVASCRIPT,
|
|
57
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
58
|
+
...GLOB_FILES_VUE,
|
|
59
|
+
],
|
|
60
|
+
settings: {
|
|
61
|
+
jsdoc: {
|
|
62
|
+
// We use the alias for legacy reasons to prevent unnecessary noise
|
|
63
|
+
tagNamePreference: {
|
|
64
|
+
returns: 'return',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
name: 'nextcloud/documentation/rules',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
rules: {
|
|
72
|
+
// Overwrites for documentation as types are already provided by Typescript
|
|
73
|
+
'jsdoc/require-param-type': 'off',
|
|
74
|
+
'jsdoc/require-property-type': 'off',
|
|
75
|
+
'jsdoc/require-returns-type': 'off',
|
|
76
|
+
},
|
|
77
|
+
files: [
|
|
78
|
+
...GLOB_FILES_TYPESCRIPT,
|
|
79
|
+
...(options.vueIsTypescript ? GLOB_FILES_VUE : []),
|
|
80
|
+
],
|
|
81
|
+
name: 'nextcloud/documentation/rules-typescript',
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* General config to exclude known non-source directories from linting
|
|
8
|
+
*/
|
|
9
|
+
export declare const filesystem: Linter.Config[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* General config to exclude known non-source directories from linting
|
|
7
|
+
*/
|
|
8
|
+
export const filesystem = [
|
|
9
|
+
{
|
|
10
|
+
name: 'nextcloud/filesystem/ignores',
|
|
11
|
+
ignores: [
|
|
12
|
+
'**/dist',
|
|
13
|
+
'**/vendor',
|
|
14
|
+
'**/vendor-bin',
|
|
15
|
+
'**/package-lock.json',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
/*!
|
|
3
|
+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import type { ConfigOptions } from '../types.d.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Generate imports and exports related ESLint rules.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Configuration options
|
|
11
|
+
*/
|
|
12
|
+
export declare function imports(options: ConfigOptions): Linter.Config[];
|