Skip to content

Commit 2185b62

Browse files
committed
fix: Relax recommended config to work also with libraries
If app info parsing was not explicitly enabled we still default to do it, but if no app info is found we do not fail but default to previous behavior of enabling all rules. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 957d471 commit 2185b62

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/configs/recommended.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
'@nextcloud',
99
],
1010
rules: {
11-
'@nextcloud/no-deprecations': ['warn', { parseAppInfo: true }],
12-
'@nextcloud/no-removed-apis': ['error', { parseAppInfo: true }],
11+
'@nextcloud/no-deprecations': ['warn'],
12+
'@nextcloud/no-removed-apis': ['error'],
1313
},
1414
};

lib/utils/version-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function createVersionValidator({ cwd, physicalFilename, options }) {
7171
}
7272

7373
// Try to find appinfo and parse the supported version
74-
if (settings?.parseAppInfo) {
74+
if (settings?.parseAppInfo !== false) {
7575
// Current working directory, either the filename (can be empty) or the cwd property
7676
const currentDirectory = path.isAbsolute(physicalFilename)
7777
? path.resolve(path.dirname(physicalFilename))
@@ -92,7 +92,11 @@ function createVersionValidator({ cwd, physicalFilename, options }) {
9292
maxVersion = sanitizeTargetVersion(maxVersion)
9393
return (version) => semver.lte(version, maxVersion)
9494
}
95-
throw Error('[@nextcloud/eslint-plugin] AppInfo parsing was enabled, but no `appinfo/info.xml` was found.')
95+
96+
if (settings?.parseAppInfo === true) {
97+
// User enforced app info parsing, so we throw an error - otherwise just fallback to default
98+
throw Error('[@nextcloud/eslint-plugin] AppInfo parsing was enabled, but no `appinfo/info.xml` was found.')
99+
}
96100
}
97101

98102
// If not configured or parsing is disabled, every rule should be handled

0 commit comments

Comments
 (0)