@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,209 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import { createVersionValidator } from "../utils/app-version-parser.js";
6
+ // ------------------------------------------------------------------------------
7
+ // Rule Definition
8
+ // ------------------------------------------------------------------------------
9
+ const global = {
10
+ $: '19.0.0',
11
+ Backbone: '18.0.0',
12
+ Clipboard: '18.0.0',
13
+ ClipboardJs: '18.0.0',
14
+ DOMPurify: '18.0.0',
15
+ formatDate: '16.0.0',
16
+ getURLParameter: '16.0.0',
17
+ Handlebars: '18.0.0',
18
+ humanFileSize: '16.0.0',
19
+ initCore: '17.0.0',
20
+ jQuery: '19.0.0',
21
+ jstimezonedetect: '18.0.0',
22
+ jstz: '18.0.0',
23
+ md5: '18.0.0',
24
+ moment: '18.0.0',
25
+ oc_appconfig: '17.0.0',
26
+ oc_appswebroots: '17.0.0',
27
+ oc_capabilities: '17.0.0',
28
+ oc_config: '17.0.0',
29
+ oc_current_user: '17.0.0',
30
+ oc_debug: '17.0.0',
31
+ oc_isadmin: '17.0.0',
32
+ oc_requesttoken: '17.0.0',
33
+ oc_webroot: '17.0.0',
34
+ OCDialogs: '17.0.0',
35
+ relative_modified_date: '16.0.0',
36
+ };
37
+ const oc = {
38
+ AppConfig: '16.0.0',
39
+ L10n: '26.0.0',
40
+ SystemTags: '32.0.0',
41
+ _capabilities: '17.0.0',
42
+ addTranslations: '17.0.0',
43
+ basename: '18.0.0',
44
+ coreApps: '17.0.0',
45
+ currentUser: '19.0.0',
46
+ dialogs: '30.0.0',
47
+ dirname: '18.0.0',
48
+ encodePath: '18.0.0',
49
+ fileIsBlacklisted: '18.0.0',
50
+ filePath: '19.0.0',
51
+ generateUrl: '19.0.0',
52
+ get: '19.0.0',
53
+ getCanonicalLocale: '20.0.0',
54
+ getCurrentUser: '19.0.0',
55
+ getHost: '17.0.0',
56
+ getHostName: '17.0.0',
57
+ getPort: '17.0.0',
58
+ getProtocol: '17.0.0',
59
+ getRootPath: '19.0.0',
60
+ imagePath: '19.0.0',
61
+ isSamePath: '18.0.0',
62
+ joinPaths: '18.0.0',
63
+ linkTo: '19.0.0',
64
+ linkToOCS: '19.0.0',
65
+ linkToRemote: '19.0.0',
66
+ set: '19.0.0',
67
+ webroot: '19.0.0',
68
+ };
69
+ const oca = {
70
+ Search: '20.0.0',
71
+ };
72
+ const ocp = {
73
+ Toast: '19.0.0',
74
+ };
75
+ const ocNested = {
76
+ Util: {
77
+ formatDate: '20.0.0',
78
+ humanFileSize: '20.0.0',
79
+ relativeModifiedDate: '20.0.0',
80
+ },
81
+ dialogs: {
82
+ fileexists: '29.0.0',
83
+ },
84
+ config: {
85
+ blacklist_files_regex: '30.0.0',
86
+ forbidden_filename_characters: '30.0.0',
87
+ },
88
+ };
89
+ const rule = {
90
+ meta: {
91
+ docs: {
92
+ description: 'Deprecated Nextcloud APIs',
93
+ recommended: true,
94
+ },
95
+ // fixable: null or "code" or "whitespace"
96
+ schema: [
97
+ {
98
+ // We accept one option which is an object
99
+ type: 'object',
100
+ properties: {
101
+ // if we should try to find an appinfo and only handle APIs removed before the max-version
102
+ parseAppInfo: {
103
+ type: 'boolean',
104
+ },
105
+ // Set a Nextcloud target version, only APIs removed before that versions are checked
106
+ targetVersion: {
107
+ type: 'string',
108
+ },
109
+ },
110
+ additionalProperties: false,
111
+ },
112
+ ],
113
+ messages: {
114
+ deprecatedGlobal: 'The global property or function {{name}} was deprecated in Nextcloud {{version}}',
115
+ },
116
+ },
117
+ create: function (context) {
118
+ const checkTargetVersion = createVersionValidator(context);
119
+ return {
120
+ MemberExpression: function (node) {
121
+ // OC.x
122
+ if ('name' in node.object
123
+ && 'name' in node.property
124
+ && node.object.name === 'OC'
125
+ && Object.hasOwn(oc, node.property.name)
126
+ && checkTargetVersion(oc[node.property.name])) {
127
+ context.report({
128
+ node,
129
+ message: `The property or function OC.${node.property.name} was deprecated in Nextcloud ${oc[node.property.name]}`,
130
+ });
131
+ }
132
+ // OCA.x
133
+ if ('name' in node.object
134
+ && 'name' in node.property
135
+ && node.object.name === 'OCA'
136
+ && Object.hasOwn(oca, node.property.name)
137
+ && checkTargetVersion(oca[node.property.name])) {
138
+ context.report({
139
+ node,
140
+ message: `The property or function OCA.${node.property.name} was deprecated in Nextcloud ${oca[node.property.name]}`,
141
+ });
142
+ }
143
+ // OCP.x
144
+ if ('name' in node.object
145
+ && 'name' in node.property
146
+ && node.object.name === 'OCP'
147
+ && Object.hasOwn(ocp, node.property.name)
148
+ && checkTargetVersion(ocp[node.property.name])) {
149
+ context.report({
150
+ node,
151
+ message: `The property or function OCP.${node.property.name} was deprecated in Nextcloud ${ocp[node.property.name]}`,
152
+ });
153
+ }
154
+ // OC.x.y
155
+ if (node.object.type === 'MemberExpression'
156
+ && 'name' in node.object.object
157
+ && node.object.object.name === 'OC'
158
+ && 'name' in node.property
159
+ && 'name' in node.object.property
160
+ && Object.hasOwn(ocNested, node.object.property.name)
161
+ && Object.hasOwn(ocNested[node.object.property.name], node.property.name)) {
162
+ const version = ocNested[node.object.property.name][node.property.name];
163
+ if (checkTargetVersion(version)) {
164
+ const prop = [
165
+ 'OC',
166
+ node.object.property.name,
167
+ node.property.name,
168
+ ].join('.');
169
+ const deprecatedSince = ocNested[node.object.property.name][node.property.name];
170
+ context.report({
171
+ node,
172
+ message: `The property or function ${prop} was deprecated in Nextcloud ${deprecatedSince}`,
173
+ });
174
+ }
175
+ }
176
+ },
177
+ Program(node) {
178
+ // Logic adapted from https://github.com/eslint/eslint/blob/master/lib/rules/no-restricted-globals.js
179
+ const scope = context.sourceCode.getScope(node);
180
+ const report = ({ identifier }) => {
181
+ if (checkTargetVersion(global[identifier.name])) {
182
+ context.report({
183
+ node,
184
+ messageId: 'deprecatedGlobal',
185
+ data: {
186
+ name: identifier.name,
187
+ version: global[identifier.name],
188
+ },
189
+ });
190
+ }
191
+ };
192
+ // Report variables declared elsewhere (ex: variables defined as "global" by eslint)
193
+ scope.variables.forEach((variable) => {
194
+ if (!variable.defs.length
195
+ && Object.hasOwn(global, variable.name)) {
196
+ variable.references.forEach(report);
197
+ }
198
+ });
199
+ // Report variables not declared at all
200
+ scope.through.forEach((reference) => {
201
+ if (Object.hasOwn(global, reference.identifier.name)) {
202
+ report(reference);
203
+ }
204
+ });
205
+ },
206
+ };
207
+ },
208
+ };
209
+ export default rule;
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import type { Rule } from 'eslint';
6
+ declare const rule: Rule.RuleModule;
7
+ export default rule;
@@ -0,0 +1,89 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import { createLibVersionValidator } from "../utils/lib-version-parser.js";
6
+ /*
7
+ Introduced in @nextcloud/vue v8.23.0
8
+ https://github.com/nextcloud-libraries/nextcloud-vue/pull/6385
9
+ */
10
+ const rule = {
11
+ meta: {
12
+ docs: {
13
+ description: 'Deprecated @nextcloud/vue import syntax',
14
+ recommended: true,
15
+ },
16
+ fixable: 'code',
17
+ messages: {
18
+ outdatedVueLibrary: 'Installed @nextcloud/vue library is outdated and does not support all reported errors. Install latest compatible version',
19
+ deprecatedDist: 'Import from "@nextcloud/vue/dist" is deprecated',
20
+ deprecatedMixin: 'Mixins are no longer recommended by Vue. Consider using available alternatives',
21
+ deprecatedNcSettingsInputText: 'NcSettingsInputText is deprecated. Consider using available alternatives',
22
+ deprecatedTooltip: 'Tooltip directive is deprecated. use native title attribute or NcPopover instead',
23
+ },
24
+ },
25
+ create(context) {
26
+ const versionSatisfies = createLibVersionValidator(context);
27
+ const isVersionValidForDist = versionSatisfies('8.23.0');
28
+ const oldPattern = '@nextcloud/vue/dist/([^/]+)/([^/.]+)';
29
+ const mixinPattern = '@nextcloud/vue/mixins/([^/.]+)';
30
+ const isVersionValidForTooltip = versionSatisfies('8.25.0');
31
+ const tooltipPattern = '@nextcloud/vue/directives/Tooltip';
32
+ const isVersionValidForNcSettingsInputText = versionSatisfies('8.31.0');
33
+ const patternForNcSettingsInputText = '@nextcloud/vue/components/NcSettingsInputText';
34
+ return {
35
+ ImportDeclaration: function (node) {
36
+ const importPath = node.source.value;
37
+ const matchForNcSettingsInputText = importPath.match(new RegExp(patternForNcSettingsInputText));
38
+ if (matchForNcSettingsInputText) {
39
+ if (!isVersionValidForNcSettingsInputText) {
40
+ context.report({ node, messageId: 'outdatedVueLibrary' });
41
+ return;
42
+ }
43
+ context.report({
44
+ node,
45
+ messageId: 'deprecatedNcSettingsInputText',
46
+ });
47
+ }
48
+ const mixinMatch = importPath.match(new RegExp(mixinPattern, 'i'));
49
+ if (mixinMatch) {
50
+ if (!isVersionValidForDist) {
51
+ context.report({ node, messageId: 'outdatedVueLibrary' });
52
+ return;
53
+ }
54
+ context.report({
55
+ node,
56
+ messageId: 'deprecatedMixin',
57
+ });
58
+ }
59
+ const tooltipMatch = importPath.match(new RegExp(tooltipPattern));
60
+ if (tooltipMatch) {
61
+ if (!isVersionValidForTooltip) {
62
+ context.report({ node, messageId: 'outdatedVueLibrary' });
63
+ return;
64
+ }
65
+ context.report({
66
+ node,
67
+ messageId: 'deprecatedTooltip',
68
+ });
69
+ }
70
+ const match = importPath.match(new RegExp(oldPattern));
71
+ if (match) {
72
+ if (!isVersionValidForDist) {
73
+ context.report({ node, messageId: 'outdatedVueLibrary' });
74
+ return;
75
+ }
76
+ const newImportPath = `'@nextcloud/vue/${match[1].toLowerCase()}/${match[2]}'`;
77
+ context.report({
78
+ node,
79
+ messageId: 'deprecatedDist',
80
+ fix(fixer) {
81
+ return fixer.replaceText(node.source, newImportPath);
82
+ },
83
+ });
84
+ }
85
+ },
86
+ };
87
+ },
88
+ };
89
+ export default rule;
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ import type { Rule } from 'eslint';
6
+ declare const _default: {
7
+ meta: {
8
+ docs: {
9
+ description: string;
10
+ };
11
+ type: "problem";
12
+ fixable: "code";
13
+ messages: {
14
+ outdatedVueLibrary: string;
15
+ useTypeInstead: string;
16
+ useVariantInstead: string;
17
+ useDisableSwipeForNavInstead: string;
18
+ useHideStatusInstead: string;
19
+ useVerboseStatusInstead: string;
20
+ useNoPlaceholderInstead: string;
21
+ useFormatInstead: string;
22
+ useLocaleInstead: string;
23
+ useTypeDateRangeInstead: string;
24
+ useNoCloseInstead: string;
25
+ useNoCloseOnClickOutsideInstead: string;
26
+ useDisableSwipeForModalInstead: string;
27
+ useNoFocusTrapInstead: string;
28
+ useKeepOpenInstead: string;
29
+ useNcSelectUsersInstead: string;
30
+ useArrowEndInstead: string;
31
+ removeAriaHidden: string;
32
+ removeLimitWidth: string;
33
+ removeExact: string;
34
+ useCloseButtonOutsideInstead: string;
35
+ useModelValueInsteadChecked: string;
36
+ useModelValueInsteadValue: string;
37
+ };
38
+ };
39
+ create(context: Rule.RuleContext): Rule.RuleListener;
40
+ };
41
+ export default _default;