@nextcloud/eslint-config 9.0.0-rc.1 → 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.
- package/CHANGELOG.md +114 -42
- package/README.md +85 -31
- package/dist/configs/codeStyle.d.ts +1 -1
- package/dist/configs/codeStyle.js +27 -29
- package/dist/configs/documentation.js +71 -38
- package/dist/configs/filesystem.js +10 -3
- package/dist/configs/imports.d.ts +1 -1
- package/dist/configs/imports.js +15 -18
- package/dist/configs/javascript.js +2 -2
- package/dist/configs/typescript.js +8 -1
- package/dist/configs/vue.js +36 -12
- package/dist/configs/vue2.js +2 -2
- package/dist/configs/vue3.js +24 -0
- package/dist/globs.d.ts +2 -0
- package/dist/globs.js +6 -2
- package/dist/index.d.ts +11 -7
- package/dist/index.js +4 -1
- package/dist/plugins/import-extensions/index.d.ts +15 -0
- package/dist/plugins/{nextcloud-vue → import-extensions}/index.js +4 -0
- package/dist/plugins/import-extensions/rules/ban-inline-type-imports.d.ts +7 -0
- package/dist/plugins/import-extensions/rules/ban-inline-type-imports.js +176 -0
- package/dist/plugins/import-extensions/rules/extensions.d.ts +11 -0
- package/dist/plugins/import-extensions/rules/extensions.js +143 -0
- package/dist/plugins/import-extensions/rules/index.d.ts +8 -0
- package/dist/plugins/import-extensions/rules/index.js +10 -0
- package/dist/plugins/nextcloud/rules/index.js +16 -4
- package/dist/plugins/nextcloud/rules/l10n-enforce-ellipsis.js +44 -0
- package/dist/plugins/{l10n/rules/non-breaking-space.js → nextcloud/rules/l10n-non-breaking-space.js} +11 -2
- package/dist/plugins/nextcloud/rules/{no-deprecations.js → no-deprecated-globals.js} +16 -3
- package/dist/plugins/nextcloud/rules/no-deprecated-library-exports.js +89 -0
- package/dist/plugins/nextcloud/rules/no-deprecated-library-props.d.ts +41 -0
- package/dist/plugins/nextcloud/rules/no-deprecated-library-props.js +429 -0
- package/dist/plugins/nextcloud/rules/{no-removed-apis.js → no-removed-globals.js} +53 -2
- package/dist/plugins/nextcloud/utils/lib-version-parser.d.ts +18 -0
- package/dist/plugins/nextcloud/utils/lib-version-parser.js +49 -0
- package/dist/plugins/nextcloud/utils/vue-template-visitor.d.ts +26 -0
- package/dist/plugins/nextcloud/utils/vue-template-visitor.js +38 -0
- package/dist/utils.d.ts +1 -12
- package/package.json +31 -25
- package/dist/plugins/l10n/index.d.ts +0 -10
- package/dist/plugins/l10n/index.js +0 -17
- package/dist/plugins/l10n/rules/enforce-ellipsis.js +0 -32
- package/dist/plugins/nextcloud-vue/index.d.ts +0 -8
- package/dist/plugins/nextcloud-vue/rules/index.d.ts +0 -6
- package/dist/plugins/nextcloud-vue/rules/index.js +0 -4
- package/dist/plugins/nextcloud-vue/rules/no-deprecated-exports.js +0 -44
- package/dist/plugins/nextcloud-vue/utils/lib-version-parser.d.ts +0 -33
- package/dist/plugins/nextcloud-vue/utils/lib-version-parser.js +0 -94
- /package/dist/plugins/{l10n/rules/enforce-ellipsis.d.ts → nextcloud/rules/l10n-enforce-ellipsis.d.ts} +0 -0
- /package/dist/plugins/{l10n/rules/non-breaking-space.d.ts → nextcloud/rules/l10n-non-breaking-space.d.ts} +0 -0
- /package/dist/plugins/{nextcloud-vue/rules/no-deprecated-exports.d.ts → nextcloud/rules/no-deprecated-globals.d.ts} +0 -0
- /package/dist/plugins/nextcloud/rules/{no-deprecations.d.ts → no-deprecated-library-exports.d.ts} +0 -0
- /package/dist/plugins/nextcloud/rules/{no-removed-apis.d.ts → no-removed-globals.d.ts} +0 -0
- /package/dist/plugins/nextcloud/utils/{version-parser.d.ts → app-version-parser.d.ts} +0 -0
- /package/dist/plugins/nextcloud/utils/{version-parser.js → app-version-parser.js} +0 -0
package/dist/utils.d.ts
CHANGED
|
@@ -9,15 +9,4 @@ import type { Linter } from 'eslint';
|
|
|
9
9
|
* @param configs The configs to restrict
|
|
10
10
|
* @param files The glob pattern to assign
|
|
11
11
|
*/
|
|
12
|
-
export declare function restrictConfigFiles(configs: Linter.Config[], files: string[]):
|
|
13
|
-
files: (string | string[])[];
|
|
14
|
-
name?: string;
|
|
15
|
-
ignores?: string[];
|
|
16
|
-
language?: string;
|
|
17
|
-
languageOptions?: Linter.LanguageOptions;
|
|
18
|
-
linterOptions?: Linter.LinterOptions;
|
|
19
|
-
processor?: string | Linter.Processor;
|
|
20
|
-
plugins?: Record<string, import("eslint").ESLint.Plugin>;
|
|
21
|
-
rules?: Partial<Linter.RulesRecord>;
|
|
22
|
-
settings?: Record<string, unknown>;
|
|
23
|
-
}[];
|
|
12
|
+
export declare function restrictConfigFiles(configs: Linter.Config[], files: string[]): Linter.Config[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextcloud/eslint-config",
|
|
3
|
-
"version": "9.0.0-rc.
|
|
3
|
+
"version": "9.0.0-rc.10",
|
|
4
4
|
"description": "Eslint shared config for nextcloud apps and libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -37,43 +37,49 @@
|
|
|
37
37
|
"build": "npm run build:cleanup && npm run build:source",
|
|
38
38
|
"build:cleanup": "tsc --build --clean",
|
|
39
39
|
"build:source": "tsc",
|
|
40
|
-
"lint": "
|
|
41
|
-
"lint:fix": "
|
|
40
|
+
"lint": "eslint --flag unstable_native_nodejs_ts_config",
|
|
41
|
+
"lint:fix": "eslint --flag unstable_native_nodejs_ts_config --fix",
|
|
42
|
+
"prerelease:format-changelog": "node build/format-changelog.mjs",
|
|
42
43
|
"test": "vitest run"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@eslint/
|
|
46
|
-
"@
|
|
47
|
-
"eslint-plugin
|
|
48
|
-
"eslint-
|
|
49
|
-
"eslint-plugin-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
46
|
+
"@eslint/js": "^10.0.1",
|
|
47
|
+
"@eslint/json": "^2.0.0",
|
|
48
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
49
|
+
"eslint-config-flat-gitignore": "^2.3.0",
|
|
50
|
+
"eslint-plugin-antfu": "^3.2.3",
|
|
51
|
+
"eslint-plugin-jsdoc": "^63.0.4",
|
|
52
|
+
"eslint-plugin-perfectionist": "^5.9.1",
|
|
53
|
+
"eslint-plugin-vue": "^10.9.2",
|
|
54
|
+
"fast-xml-parser": "^5.9.0",
|
|
55
|
+
"globals": "^17.6.0",
|
|
56
|
+
"semver": "^7.8.4",
|
|
57
|
+
"sort-package-json": "^4.0.0",
|
|
58
|
+
"typescript-eslint": "^8.61.1"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^
|
|
58
|
-
"@types/semver": "^7.7.
|
|
59
|
-
"eslint": "^
|
|
60
|
-
"memfs": "^4.
|
|
61
|
-
"vitest": "^
|
|
61
|
+
"@types/node": "^26.0.0",
|
|
62
|
+
"@types/semver": "^7.7.1",
|
|
63
|
+
"eslint": "^10.5.0",
|
|
64
|
+
"memfs": "^4.57.7",
|
|
65
|
+
"vitest": "^4.1.9"
|
|
62
66
|
},
|
|
63
67
|
"peerDependencies": {
|
|
64
|
-
"eslint": ">=
|
|
68
|
+
"eslint": ">=10"
|
|
65
69
|
},
|
|
66
70
|
"engines": {
|
|
67
|
-
"node": "^
|
|
71
|
+
"node": "^22.13 || ^24 || >=26"
|
|
68
72
|
},
|
|
69
73
|
"devEngines": {
|
|
70
|
-
"packageManager":
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
"packageManager": [
|
|
75
|
+
{
|
|
76
|
+
"name": "npm",
|
|
77
|
+
"version": "^11.3.0"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
74
80
|
"runtime": {
|
|
75
81
|
"name": "node",
|
|
76
|
-
"version": "^
|
|
82
|
+
"version": "^24.3.0"
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createLibVersionValidator } from "../utils/lib-version-parser.js";
|
|
2
|
-
// ------------------------------------------------------------------------------
|
|
3
|
-
// Rule Definition
|
|
4
|
-
// ------------------------------------------------------------------------------
|
|
5
|
-
/*
|
|
6
|
-
Introduced in @nextcloud/vue v8.23.0
|
|
7
|
-
https://github.com/nextcloud-libraries/nextcloud-vue/pull/6385
|
|
8
|
-
*/
|
|
9
|
-
const rule = {
|
|
10
|
-
meta: {
|
|
11
|
-
docs: {
|
|
12
|
-
description: 'Deprecated @nextcloud/vue import syntax',
|
|
13
|
-
recommended: true,
|
|
14
|
-
},
|
|
15
|
-
fixable: 'code',
|
|
16
|
-
schema: [],
|
|
17
|
-
},
|
|
18
|
-
create(context) {
|
|
19
|
-
const versionSatisfies = createLibVersionValidator(context);
|
|
20
|
-
const isVersionValid = versionSatisfies('8.23.0');
|
|
21
|
-
const oldPattern = '@nextcloud/vue/dist/([^/]+)/([^/.]+)';
|
|
22
|
-
return {
|
|
23
|
-
ImportDeclaration: function (node) {
|
|
24
|
-
if (!isVersionValid) {
|
|
25
|
-
// Can't fix, ignore the rule
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const importPath = node.source.value;
|
|
29
|
-
const match = importPath.match(new RegExp(oldPattern));
|
|
30
|
-
if (match) {
|
|
31
|
-
const newImportPath = `'@nextcloud/vue/${match[1].toLowerCase()}/${match[2]}'`;
|
|
32
|
-
context.report({
|
|
33
|
-
node,
|
|
34
|
-
message: 'Import from "@nextcloud/vue/dist" is deprecated',
|
|
35
|
-
fix(fixer) {
|
|
36
|
-
return fixer.replaceText(node.source, newImportPath);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
export default rule;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a given path exists and is a file
|
|
3
|
-
*
|
|
4
|
-
* @param filePath The path
|
|
5
|
-
*/
|
|
6
|
-
export declare function isFile(filePath: string): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Find the path of nearest `package.json` relative to given path
|
|
9
|
-
*
|
|
10
|
-
* @param currentPath Path to lookup
|
|
11
|
-
* @return Either the full path where `package.json` is located or `undefined` if no found
|
|
12
|
-
*/
|
|
13
|
-
export declare function findPackageJsonDir(currentPath: string): string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Make sure that versions like '25' can be handled by semver
|
|
16
|
-
*
|
|
17
|
-
* @param version The pure version string
|
|
18
|
-
* @return Sanitized version string
|
|
19
|
-
*/
|
|
20
|
-
export declare function sanitizeTargetVersion(version: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Create a callback that takes a version number and checks if the version
|
|
23
|
-
* is valid compared to configured version / detected version.
|
|
24
|
-
*
|
|
25
|
-
* @param options Options
|
|
26
|
-
* @param options.cwd The current working directory
|
|
27
|
-
* @param options.physicalFilename The real filename where ESLint is linting currently
|
|
28
|
-
* @return Function validator, return a boolean whether current version satisfies minimal required for the rule
|
|
29
|
-
*/
|
|
30
|
-
export declare function createLibVersionValidator({ cwd, physicalFilename }: {
|
|
31
|
-
cwd: any;
|
|
32
|
-
physicalFilename: any;
|
|
33
|
-
}): ((version: string) => boolean);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
3
|
-
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
-
*/
|
|
5
|
-
import { lstatSync, readFileSync } from 'node:fs';
|
|
6
|
-
import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
7
|
-
import { gte, minVersion, valid } from 'semver';
|
|
8
|
-
/**
|
|
9
|
-
* Cached map of paths: Reco <path_to_package.json, validator>
|
|
10
|
-
*/
|
|
11
|
-
const cachedMap = {};
|
|
12
|
-
/**
|
|
13
|
-
* Check if a given path exists and is a file
|
|
14
|
-
*
|
|
15
|
-
* @param filePath The path
|
|
16
|
-
*/
|
|
17
|
-
export function isFile(filePath) {
|
|
18
|
-
const stats = lstatSync(filePath, { throwIfNoEntry: false });
|
|
19
|
-
return stats !== undefined && stats.isFile();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Find the path of nearest `package.json` relative to given path
|
|
23
|
-
*
|
|
24
|
-
* @param currentPath Path to lookup
|
|
25
|
-
* @return Either the full path where `package.json` is located or `undefined` if no found
|
|
26
|
-
*/
|
|
27
|
-
export function findPackageJsonDir(currentPath) {
|
|
28
|
-
for (const cachedDirPath of Object.keys(cachedMap)) {
|
|
29
|
-
if (currentPath.startsWith(cachedDirPath)) {
|
|
30
|
-
return cachedDirPath;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
while (currentPath && currentPath !== sep) {
|
|
34
|
-
if (isFile(join(currentPath, 'package.json'))) {
|
|
35
|
-
return currentPath;
|
|
36
|
-
}
|
|
37
|
-
currentPath = resolve(currentPath, '..');
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Make sure that versions like '25' can be handled by semver
|
|
43
|
-
*
|
|
44
|
-
* @param version The pure version string
|
|
45
|
-
* @return Sanitized version string
|
|
46
|
-
*/
|
|
47
|
-
export function sanitizeTargetVersion(version) {
|
|
48
|
-
const sanitizedVersion = minVersion(version)?.version;
|
|
49
|
-
// now version should look like '23.0.0'
|
|
50
|
-
if (!valid(sanitizedVersion)) {
|
|
51
|
-
throw Error(`[@nextcloud/eslint-plugin] Invalid target version ${version} found`);
|
|
52
|
-
}
|
|
53
|
-
return sanitizedVersion;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a callback that takes a version number and checks if the version
|
|
57
|
-
* is valid compared to configured version / detected version.
|
|
58
|
-
*
|
|
59
|
-
* @param options Options
|
|
60
|
-
* @param options.cwd The current working directory
|
|
61
|
-
* @param options.physicalFilename The real filename where ESLint is linting currently
|
|
62
|
-
* @return Function validator, return a boolean whether current version satisfies minimal required for the rule
|
|
63
|
-
*/
|
|
64
|
-
export function createLibVersionValidator({ cwd, physicalFilename }) {
|
|
65
|
-
// Try to find package.json and parse the supported version
|
|
66
|
-
// Current working directory, either the filename (can be empty) or the cwd property
|
|
67
|
-
const currentDirectory = isAbsolute(physicalFilename)
|
|
68
|
-
? resolve(dirname(physicalFilename))
|
|
69
|
-
: dirname(resolve(cwd, physicalFilename));
|
|
70
|
-
// The nearest package.json
|
|
71
|
-
const packageJsonDir = findPackageJsonDir(currentDirectory);
|
|
72
|
-
if (!packageJsonDir) {
|
|
73
|
-
// Skip the rule
|
|
74
|
-
return () => false;
|
|
75
|
-
}
|
|
76
|
-
else if (cachedMap[packageJsonDir]) {
|
|
77
|
-
return cachedMap[packageJsonDir];
|
|
78
|
-
}
|
|
79
|
-
const json = JSON.parse(readFileSync(join(packageJsonDir, 'package.json'), 'utf-8'));
|
|
80
|
-
const libVersions = [
|
|
81
|
-
json?.dependencies?.['@nextcloud/vue'],
|
|
82
|
-
json?.devDependencies?.['@nextcloud/vue'],
|
|
83
|
-
json?.peerDependencies?.['@nextcloud/vue'],
|
|
84
|
-
]
|
|
85
|
-
.filter((version) => typeof version === 'string' && !!version)
|
|
86
|
-
.map(sanitizeTargetVersion)
|
|
87
|
-
.sort((a, b) => gte(a, b) ? 1 : -1);
|
|
88
|
-
if (!libVersions.length) {
|
|
89
|
-
// Skip the rule
|
|
90
|
-
return () => false;
|
|
91
|
-
}
|
|
92
|
-
// Return, whether given version satisfies minimal version from dependencies
|
|
93
|
-
return (version) => gte(libVersions[0], version);
|
|
94
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/plugins/nextcloud/rules/{no-deprecations.d.ts → no-deprecated-library-exports.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|