@nextcloud/eslint-config 9.0.0-rc.0 → 9.0.0-rc.10

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +133 -44
  2. package/README.md +139 -33
  3. package/dist/configs/codeStyle.d.ts +13 -0
  4. package/dist/configs/codeStyle.js +176 -0
  5. package/dist/configs/documentation.d.ts +12 -0
  6. package/dist/configs/documentation.js +117 -0
  7. package/dist/configs/filesystem.d.ts +9 -0
  8. package/dist/configs/filesystem.js +25 -0
  9. package/dist/configs/imports.d.ts +12 -0
  10. package/dist/configs/imports.js +111 -0
  11. package/dist/configs/javascript.d.ts +14 -0
  12. package/dist/configs/javascript.js +118 -0
  13. package/dist/configs/json.d.ts +9 -0
  14. package/dist/configs/json.js +45 -0
  15. package/dist/configs/node.d.ts +10 -0
  16. package/dist/configs/node.js +24 -0
  17. package/dist/configs/typescript.d.ts +12 -0
  18. package/dist/configs/typescript.js +60 -0
  19. package/dist/configs/vue.d.ts +12 -0
  20. package/dist/configs/vue.js +158 -0
  21. package/dist/configs/vue2.d.ts +12 -0
  22. package/dist/configs/vue2.js +30 -0
  23. package/dist/configs/vue3.d.ts +12 -0
  24. package/dist/configs/vue3.js +48 -0
  25. package/dist/globs.d.ts +20 -0
  26. package/dist/globs.js +41 -0
  27. package/dist/index.d.ts +31 -31
  28. package/dist/index.js +81 -0
  29. package/dist/plugins/import-extensions/index.d.ts +15 -0
  30. package/dist/plugins/import-extensions/index.js +13 -0
  31. package/dist/plugins/import-extensions/rules/ban-inline-type-imports.d.ts +7 -0
  32. package/dist/plugins/import-extensions/rules/ban-inline-type-imports.js +176 -0
  33. package/dist/plugins/import-extensions/rules/extensions.d.ts +11 -0
  34. package/dist/plugins/import-extensions/rules/extensions.js +143 -0
  35. package/dist/plugins/import-extensions/rules/index.d.ts +8 -0
  36. package/dist/plugins/import-extensions/rules/index.js +10 -0
  37. package/dist/plugins/nextcloud/index.d.ts +7 -0
  38. package/dist/plugins/nextcloud/index.js +9 -0
  39. package/dist/plugins/nextcloud/rules/index.d.ts +6 -0
  40. package/dist/plugins/nextcloud/rules/index.js +18 -0
  41. package/dist/plugins/nextcloud/rules/l10n-enforce-ellipsis.d.ts +7 -0
  42. package/dist/plugins/nextcloud/rules/l10n-enforce-ellipsis.js +44 -0
  43. package/dist/plugins/nextcloud/rules/l10n-non-breaking-space.d.ts +7 -0
  44. package/dist/plugins/nextcloud/rules/l10n-non-breaking-space.js +39 -0
  45. package/dist/plugins/nextcloud/rules/no-deprecated-globals.d.ts +7 -0
  46. package/dist/plugins/nextcloud/rules/no-deprecated-globals.js +209 -0
  47. package/dist/plugins/nextcloud/rules/no-deprecated-library-exports.d.ts +7 -0
  48. package/dist/plugins/nextcloud/rules/no-deprecated-library-exports.js +89 -0
  49. package/dist/plugins/nextcloud/rules/no-deprecated-library-props.d.ts +41 -0
  50. package/dist/plugins/nextcloud/rules/no-deprecated-library-props.js +429 -0
  51. package/dist/plugins/nextcloud/rules/no-removed-globals.d.ts +7 -0
  52. package/dist/plugins/nextcloud/rules/no-removed-globals.js +203 -0
  53. package/dist/plugins/nextcloud/utils/app-version-parser.d.ts +41 -0
  54. package/dist/plugins/nextcloud/utils/app-version-parser.js +106 -0
  55. package/dist/plugins/nextcloud/utils/lib-version-parser.d.ts +18 -0
  56. package/dist/plugins/nextcloud/utils/lib-version-parser.js +49 -0
  57. package/dist/plugins/nextcloud/utils/vue-template-visitor.d.ts +26 -0
  58. package/dist/plugins/nextcloud/utils/vue-template-visitor.js +38 -0
  59. package/dist/plugins/packageJson.d.ts +10 -0
  60. package/dist/plugins/packageJson.js +66 -0
  61. package/dist/utils.d.ts +12 -0
  62. package/dist/utils.js +19 -0
  63. package/dist/version.d.ts +1 -0
  64. package/dist/version.js +6 -0
  65. package/package.json +35 -27
  66. package/dist/index.mjs +0 -1464
  67. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,176 @@
1
+ import stylistic from '@stylistic/eslint-plugin';
2
+ import eslintAntfuPlugin from 'eslint-plugin-antfu';
3
+ import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.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
+ plugins: {
38
+ antfu: eslintAntfuPlugin,
39
+ },
40
+ rules: {
41
+ // Overrides for the stylistic recommended rules
42
+ // Tabs should only be used for indention
43
+ '@stylistic/no-tabs': [
44
+ 'error',
45
+ { allowIndentationTabs: true },
46
+ ],
47
+ // allow spaces after tabs for alignment
48
+ '@stylistic/no-mixed-spaces-and-tabs': [
49
+ 'error',
50
+ 'smart-tabs',
51
+ ],
52
+ // allow backticks for strings that contain single quotes
53
+ '@stylistic/quotes': [
54
+ 'error',
55
+ 'single',
56
+ {
57
+ allowTemplateLiterals: 'never',
58
+ avoidEscape: true,
59
+ },
60
+ ],
61
+ // Not included in stylistic preset but set by us:
62
+ // Enforce camelCase but allow legacy webpack variables
63
+ camelcase: [
64
+ 'error',
65
+ {
66
+ allow: ['^__webpack_'],
67
+ properties: 'never',
68
+ ignoreGlobals: true,
69
+ },
70
+ ],
71
+ // Make sure to use object shorthand properties
72
+ 'object-shorthand': [
73
+ 'error',
74
+ 'properties',
75
+ { avoidQuotes: true },
76
+ ],
77
+ // Enforce consistent new lines after brackets
78
+ '@stylistic/array-bracket-newline': 'off',
79
+ '@stylistic/array-bracket-spacing': 'off',
80
+ '@stylistic/array-element-newline': 'off',
81
+ '@stylistic/jsx-function-call-newline': 'off',
82
+ '@stylistic/object-curly-newline': 'off',
83
+ '@stylistic/object-curly-spacing': 'off',
84
+ '@stylistic/object-property-newline': 'off',
85
+ '@stylistic/exp-list-style': ['error', {
86
+ singleLine: {
87
+ spacing: 'never',
88
+ },
89
+ overrides: {
90
+ '{}': {
91
+ singleLine: { spacing: 'always' },
92
+ },
93
+ },
94
+ }],
95
+ // No space between function name and parenthesis. Enforce fn() instead of fn ()
96
+ '@stylistic/function-call-spacing': [
97
+ 'error',
98
+ 'never',
99
+ ],
100
+ // No space between function name and parenthesis on definition. Enforce `function foo()` instead of `function foo ()`.
101
+ '@stylistic/space-before-function-paren': [
102
+ 'error',
103
+ {
104
+ // good: `function() {}` bad: `function () {}`
105
+ anonymous: 'never',
106
+ // good `function foo() {}` bad: `function foo () {}`
107
+ named: 'never',
108
+ // consistency for arrow functions regardless of async or sync:
109
+ // good `async () => {}` bad `async() => {}`
110
+ asyncArrow: 'always',
111
+ },
112
+ ],
113
+ // Enforce consistent newlines in function parameters, if one parameter is separated by newline, than all should
114
+ '@stylistic/function-call-argument-newline': [
115
+ 'error',
116
+ 'consistent',
117
+ ],
118
+ // If parameters are separated by newlines, then the first one should also be separated by a newline from the parenthesis
119
+ '@stylistic/function-paren-newline': [
120
+ 'error',
121
+ 'multiline',
122
+ ],
123
+ // Generator functions should have the * on the function keyword as this defines the type of function. "function* generator()"
124
+ '@stylistic/generator-star-spacing': [
125
+ 'error',
126
+ 'after',
127
+ ],
128
+ // Arrow functions with implicit return should not have line breaks
129
+ // TODO: Discuss
130
+ '@stylistic/implicit-arrow-linebreak': [
131
+ 'error',
132
+ 'beside',
133
+ ],
134
+ // Prevent issues with different OS by enforcing single line feed for new lien
135
+ '@stylistic/linebreak-style': [
136
+ 'error',
137
+ 'unix',
138
+ ],
139
+ // No useless semicolons
140
+ '@stylistic/no-extra-semi': ['error'],
141
+ 'no-useless-concat': 'error',
142
+ // Prefer { ...foo } over Object.assign({}, foo)
143
+ 'prefer-object-spread': 'warn',
144
+ // Enforce function declarations for top level functions
145
+ 'antfu/top-level-function': 'error',
146
+ },
147
+ },
148
+ {
149
+ name: 'nextcloud/stylistic/ts-rules',
150
+ files: [
151
+ ...GLOB_FILES_TYPESCRIPT,
152
+ ...(options.vueIsTypescript ? GLOB_FILES_VUE : []),
153
+ ],
154
+ rules: {
155
+ // consistent spacing for types
156
+ '@stylistic/type-annotation-spacing': 'error',
157
+ // consistent spacing for generics
158
+ '@stylistic/type-generic-spacing': 'error',
159
+ '@stylistic/type-named-tuple-spacing': 'error',
160
+ },
161
+ },
162
+ {
163
+ name: 'nextcloud/stylistic/l10n',
164
+ files: [
165
+ ...GLOB_FILES_JAVASCRIPT,
166
+ ...GLOB_FILES_TYPESCRIPT,
167
+ ...GLOB_FILES_VUE,
168
+ ],
169
+ // Enforce that translations use ellipsis instead of tripple dots
170
+ rules: {
171
+ '@nextcloud/l10n-non-breaking-space': 'error',
172
+ '@nextcloud/l10n-enforce-ellipsis': 'error',
173
+ },
174
+ },
175
+ ];
176
+ }
@@ -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,117 @@
1
+ import { jsdoc } from 'eslint-plugin-jsdoc';
2
+ import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TESTING, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
3
+ const TS_FUNCTION_CONTEXTS = [
4
+ 'FunctionDeclaration:has(TSTypeAnnotation)',
5
+ 'FunctionExpression:has(TSTypeAnnotation)',
6
+ 'ArrowFunctionExpression:has(TSTypeAnnotation)',
7
+ 'MethodDefinition:has(TSTypeAnnotation)',
8
+ ];
9
+ const JS_FUNCTION_CONTEXTS = [
10
+ 'FunctionDeclaration:not(:has(TSTypeAnnotation))',
11
+ 'FunctionExpression:not(:has(TSTypeAnnotation))',
12
+ 'ArrowFunctionExpression:not(:has(TSTypeAnnotation))',
13
+ 'MethodDefinition:not(:has(TSTypeAnnotation))',
14
+ ];
15
+ const SHARED_JSDOC_SETTINGS = {
16
+ // We use the alias for legacy reasons to prevent unnecessary noise
17
+ tagNamePreference: {
18
+ returns: 'return',
19
+ },
20
+ };
21
+ /**
22
+ * Config factory for code documentation related rules (JSDoc)
23
+ *
24
+ * @param options options defining the config preset flavor
25
+ */
26
+ export function documentation(options) {
27
+ return [
28
+ {
29
+ ...jsdoc({
30
+ config: 'flat/recommended-typescript-flavor',
31
+ settings: {
32
+ ...SHARED_JSDOC_SETTINGS,
33
+ mode: 'permissive',
34
+ },
35
+ }),
36
+ name: 'nextcloud/documentation/javascript',
37
+ files: [
38
+ ...GLOB_FILES_JAVASCRIPT,
39
+ ...(options.vueIsTypescript ? [] : GLOB_FILES_VUE),
40
+ ],
41
+ ignores: GLOB_FILES_TESTING,
42
+ },
43
+ {
44
+ ...jsdoc({
45
+ config: 'flat/recommended-typescript',
46
+ settings: SHARED_JSDOC_SETTINGS,
47
+ }),
48
+ name: 'nextcloud/documentation/typescript',
49
+ files: [
50
+ ...GLOB_FILES_TYPESCRIPT,
51
+ ...(options.vueIsTypescript ? GLOB_FILES_VUE : []),
52
+ ],
53
+ ignores: GLOB_FILES_TESTING,
54
+ },
55
+ {
56
+ name: 'nextcloud/documentation/rules',
57
+ files: [
58
+ ...GLOB_FILES_JAVASCRIPT,
59
+ ...GLOB_FILES_TYPESCRIPT,
60
+ ...GLOB_FILES_VUE,
61
+ ],
62
+ ignores: GLOB_FILES_TESTING,
63
+ rules: {
64
+ // Force proper documentation
65
+ 'jsdoc/check-tag-names': 'error',
66
+ // But ignore return values
67
+ 'jsdoc/require-returns': 'off',
68
+ 'jsdoc/require-returns-description': 'off',
69
+ // Allow one empty line in jsdoc blocks
70
+ 'jsdoc/tag-lines': [
71
+ 'warn',
72
+ 'any',
73
+ { startLines: 1 },
74
+ ],
75
+ },
76
+ },
77
+ {
78
+ name: 'nextcloud/documentation/rules-typescript',
79
+ files: [...GLOB_FILES_TYPESCRIPT],
80
+ ignores: GLOB_FILES_TESTING,
81
+ rules: {
82
+ // Overwrites for documentation as types are already provided by Typescript
83
+ 'jsdoc/no-types': 'error',
84
+ 'jsdoc/require-param-type': 'off',
85
+ 'jsdoc/require-returns-type': 'off',
86
+ },
87
+ },
88
+ ...(options.vueIsTypescript
89
+ ? [
90
+ {
91
+ name: 'nextcloud/documentation/rules-vue',
92
+ files: [...(options.vueIsTypescript ? GLOB_FILES_VUE : [])],
93
+ ignores: GLOB_FILES_TESTING,
94
+ rules: {
95
+ // Vue files can be both Javascript and Typescript
96
+ // Try to apply TS files only for functions with TS definitions
97
+ 'jsdoc/no-types': [
98
+ 'error',
99
+ { contexts: TS_FUNCTION_CONTEXTS },
100
+ ],
101
+ 'jsdoc/require-param-type': [
102
+ 'error',
103
+ { contexts: JS_FUNCTION_CONTEXTS },
104
+ ],
105
+ // Unlike params, return values are often inferred and not explicitly typed
106
+ 'jsdoc/require-returns-type': 'off',
107
+ // Unfortunately, we cannot check when it is used in TS context and when not
108
+ 'jsdoc/check-tag-names': [
109
+ 'error',
110
+ { typed: false },
111
+ ],
112
+ },
113
+ },
114
+ ]
115
+ : []),
116
+ ];
117
+ }
@@ -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,25 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import gitignore from 'eslint-config-flat-gitignore';
6
+ /**
7
+ * General config to exclude known non-source directories from linting
8
+ */
9
+ export const filesystem = [
10
+ {
11
+ ...gitignore(),
12
+ name: 'nextcloud/filesystem/gitignore',
13
+ },
14
+ {
15
+ name: 'nextcloud/filesystem/ignores',
16
+ ignores: [
17
+ 'dist/',
18
+ 'js/',
19
+ 'l10n/',
20
+ 'vendor/',
21
+ 'vendor-bin/',
22
+ '**/package-lock.json',
23
+ ],
24
+ },
25
+ ];
@@ -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
+ * Generate imports and exports related ESLint rules.
9
+ *
10
+ * @param options - Configuration options
11
+ */
12
+ export declare function imports(options: ConfigOptions): Linter.Config[];
@@ -0,0 +1,111 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import perfectionist from 'eslint-plugin-perfectionist';
6
+ import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
7
+ import importExtensions from "../plugins/import-extensions/index.js";
8
+ /**
9
+ * Generate imports and exports related ESLint rules.
10
+ *
11
+ * @param options - Configuration options
12
+ */
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+ export function imports(options) {
15
+ return [
16
+ {
17
+ name: 'nextcloud/imports/setup',
18
+ plugins: {
19
+ perfectionist,
20
+ 'import-extensions': importExtensions,
21
+ },
22
+ },
23
+ {
24
+ name: 'nextcloud/imports/rules',
25
+ files: [
26
+ ...GLOB_FILES_JAVASCRIPT,
27
+ ...GLOB_FILES_TYPESCRIPT,
28
+ ...GLOB_FILES_VUE,
29
+ ],
30
+ rules: {
31
+ // Require file extensions
32
+ 'import-extensions/extensions': 'error',
33
+ // enforce explicit type imports (no inline types)
34
+ 'import-extensions/ban-inline-type-imports': 'error',
35
+ // Sorting of imports
36
+ 'sort-imports': 'off',
37
+ 'perfectionist/sort-imports': [
38
+ 'error',
39
+ {
40
+ type: 'natural',
41
+ newlinesBetween: 0,
42
+ groups: [
43
+ // type first
44
+ ['type-external', 'type-builtin'],
45
+ 'type-import',
46
+ { newlinesBetween: 1 },
47
+ // external things
48
+ [
49
+ 'builtin',
50
+ 'external',
51
+ ],
52
+ // Vue components
53
+ 'vue', // external modules (e.g. nextcloud-vue)
54
+ 'internalVue', // internal local vue components
55
+ // everything else which is everything internal
56
+ 'unknown',
57
+ { newlinesBetween: 1 },
58
+ // side effect only: import 'sideeffect.js'
59
+ 'side-effect',
60
+ // import style from 'my.module.css'
61
+ 'style',
62
+ ],
63
+ customGroups: [
64
+ {
65
+ groupName: 'vue',
66
+ selector: 'external',
67
+ modifiers: ['value'],
68
+ elementNamePattern: [
69
+ '\\.vue$',
70
+ '@nextcloud/vue/components/',
71
+ ],
72
+ },
73
+ {
74
+ groupName: 'internalVue',
75
+ modifiers: ['value'],
76
+ elementNamePattern: ['\\.vue$'],
77
+ },
78
+ ],
79
+ },
80
+ ],
81
+ 'perfectionist/sort-named-exports': [
82
+ 'error',
83
+ createSortingConfig('export'),
84
+ ],
85
+ 'perfectionist/sort-named-imports': [
86
+ 'error',
87
+ createSortingConfig('import'),
88
+ ],
89
+ },
90
+ },
91
+ ];
92
+ }
93
+ /**
94
+ * Create the same rule config for exports and import.
95
+ *
96
+ * @param type The type for which to create the config
97
+ */
98
+ function createSortingConfig(type) {
99
+ return {
100
+ type: 'natural',
101
+ newlinesBetween: 0,
102
+ partitionByNewLine: false,
103
+ groups: [
104
+ `type-${type}`,
105
+ [
106
+ `value-${type}`,
107
+ 'unknown',
108
+ ],
109
+ ],
110
+ };
111
+ }
@@ -0,0 +1,14 @@
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
+ * This config provides the base rules for code quality,
9
+ * the target is a good code quality -> prevent bugs,
10
+ * code style is handled by another config.
11
+ *
12
+ * @param options - Configuration options
13
+ */
14
+ export declare function javascript(options: ConfigOptions): Linter.Config[];
@@ -0,0 +1,118 @@
1
+ import eslintRules from '@eslint/js';
2
+ import globals from 'globals';
3
+ import { GLOB_FILES_JAVASCRIPT, GLOB_FILES_TESTING, GLOB_FILES_TYPESCRIPT, GLOB_FILES_VUE, } from "../globs.js";
4
+ import nextcloudPlugin from "../plugins/nextcloud/index.js";
5
+ /**
6
+ * This config provides the base rules for code quality,
7
+ * the target is a good code quality -> prevent bugs,
8
+ * code style is handled by another config.
9
+ *
10
+ * @param options - Configuration options
11
+ */
12
+ export function javascript(options) {
13
+ return [
14
+ {
15
+ name: 'nextcloud/javascript/setup',
16
+ languageOptions: {
17
+ ecmaVersion: 'latest',
18
+ globals: {
19
+ ...globals.browser,
20
+ ...globals.es2025,
21
+ OC: 'readonly',
22
+ OCA: 'writable',
23
+ OCP: 'readonly',
24
+ // injected by shared Vite and Webpack config
25
+ appName: 'readonly',
26
+ appVersion: 'readonly',
27
+ // legacy global Nextcloud translation function
28
+ t: 'readonly',
29
+ n: 'readonly',
30
+ // webpack support
31
+ __webpack_nonce__: 'writable',
32
+ },
33
+ parserOptions: {
34
+ ecmaFeatures: {
35
+ jsx: true,
36
+ },
37
+ ecmaVersion: 'latest',
38
+ sourceType: 'module',
39
+ },
40
+ sourceType: 'module',
41
+ },
42
+ linterOptions: {
43
+ reportUnusedDisableDirectives: true,
44
+ },
45
+ },
46
+ // General rules we built upon
47
+ {
48
+ name: 'eslint/configs/recommended',
49
+ files: [
50
+ ...GLOB_FILES_JAVASCRIPT,
51
+ ...GLOB_FILES_TYPESCRIPT,
52
+ ...GLOB_FILES_VUE,
53
+ ],
54
+ ...eslintRules.configs.recommended,
55
+ },
56
+ // The Nextcloud plugin for detecting deprecated and removed global API
57
+ (options.isLibrary
58
+ ? {}
59
+ : {
60
+ name: 'nextcloud/javascript/plugin',
61
+ plugins: {
62
+ '@nextcloud': nextcloudPlugin,
63
+ },
64
+ rules: {
65
+ '@nextcloud/no-deprecated-globals': ['warn'],
66
+ '@nextcloud/no-removed-globals': ['error'],
67
+ },
68
+ files: [
69
+ ...GLOB_FILES_JAVASCRIPT,
70
+ ...GLOB_FILES_TYPESCRIPT,
71
+ ...GLOB_FILES_VUE,
72
+ ],
73
+ }),
74
+ // Nextcloud specific overwrite
75
+ {
76
+ name: 'nextcloud/javascript/rules',
77
+ files: [
78
+ ...GLOB_FILES_JAVASCRIPT,
79
+ ...GLOB_FILES_TYPESCRIPT,
80
+ ...GLOB_FILES_VUE,
81
+ ],
82
+ rules: {
83
+ 'no-eval': 'error',
84
+ // Require strict checks
85
+ eqeqeq: 'error',
86
+ // Use dot notation where possible as we also only use quote where needed
87
+ 'dot-notation': 'error',
88
+ // prevent bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces
89
+ curly: [
90
+ 'error',
91
+ 'all',
92
+ ],
93
+ // disallow use of "var", use let and const - see rule description for reasons.
94
+ 'no-var': 'error',
95
+ // Prevent bugs by enforce const if variable is not changed.
96
+ 'prefer-const': 'error',
97
+ // `@nextcloud/logger` should be used
98
+ 'no-console': 'error',
99
+ // We support ES2022 so we should use `hasOwn` instead
100
+ 'prefer-object-has-own': 'error',
101
+ // Allow to write code in reading order for functions
102
+ 'no-use-before-define': [
103
+ 'error',
104
+ { functions: false },
105
+ ],
106
+ },
107
+ },
108
+ // Testing related overwrites
109
+ {
110
+ name: 'nextcloud/javascript/testing-overwrites',
111
+ files: GLOB_FILES_TESTING,
112
+ rules: {
113
+ // Allow to test console output
114
+ 'no-console': 'off',
115
+ },
116
+ },
117
+ ];
118
+ }
@@ -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
+ * JSON related ESLint rules for Nextcloud
8
+ */
9
+ export declare const json: Linter.Config[];
@@ -0,0 +1,45 @@
1
+ import jsonPlugin from '@eslint/json';
2
+ import { GLOB_FILES_JSON, GLOB_FILES_JSONC, GLOB_FILES_MS_JSON, } from "../globs.js";
3
+ import packageJsonPlugin from "../plugins/packageJson.js";
4
+ /**
5
+ * JSON related ESLint rules for Nextcloud
6
+ */
7
+ export const json = [
8
+ {
9
+ language: 'json/json',
10
+ plugins: {
11
+ json: jsonPlugin,
12
+ 'package-json': packageJsonPlugin,
13
+ },
14
+ rules: {
15
+ ...jsonPlugin.configs.recommended.rules,
16
+ },
17
+ files: GLOB_FILES_JSON,
18
+ name: 'nextcloud/json',
19
+ },
20
+ // lint package.json files
21
+ {
22
+ files: ['**/package.json'],
23
+ language: 'json/json',
24
+ rules: {
25
+ 'package-json/sort-package-json': 'error',
26
+ },
27
+ },
28
+ // Special handing of JSONC
29
+ {
30
+ files: GLOB_FILES_JSONC,
31
+ language: 'json/jsonc',
32
+ ...jsonPlugin.configs.recommended,
33
+ name: 'nextcloud/jsonc',
34
+ },
35
+ // Microsoft specific JSONC (e.g. Typescript config)
36
+ {
37
+ files: GLOB_FILES_MS_JSON,
38
+ language: 'json/jsonc',
39
+ languageOptions: {
40
+ allowTrailingCommas: true,
41
+ },
42
+ ...jsonPlugin.configs.recommended,
43
+ name: 'nextcloud/ms-json',
44
+ },
45
+ ];
@@ -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 { Linter } from 'eslint';
6
+ /**
7
+ * Config setup for the node environment.
8
+ * Config files should be parsed as Node.JS scripts with Node globals etc.
9
+ */
10
+ export declare const node: Linter.Config[];