Skip to content

Commit

Permalink
fix: Relax recommended config to work also with libraries
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
susnux committed Apr 15, 2024
1 parent 957d471 commit 2185b62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'@nextcloud',
],
rules: {
'@nextcloud/no-deprecations': ['warn', { parseAppInfo: true }],
'@nextcloud/no-removed-apis': ['error', { parseAppInfo: true }],
'@nextcloud/no-deprecations': ['warn'],
'@nextcloud/no-removed-apis': ['error'],
},
};
8 changes: 6 additions & 2 deletions lib/utils/version-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function createVersionValidator({ cwd, physicalFilename, options }) {
}

// Try to find appinfo and parse the supported version
if (settings?.parseAppInfo) {
if (settings?.parseAppInfo !== false) {
// Current working directory, either the filename (can be empty) or the cwd property
const currentDirectory = path.isAbsolute(physicalFilename)
? path.resolve(path.dirname(physicalFilename))
Expand All @@ -92,7 +92,11 @@ function createVersionValidator({ cwd, physicalFilename, options }) {
maxVersion = sanitizeTargetVersion(maxVersion)
return (version) => semver.lte(version, maxVersion)
}
throw Error('[@nextcloud/eslint-plugin] AppInfo parsing was enabled, but no `appinfo/info.xml` was found.')

if (settings?.parseAppInfo === true) {
// User enforced app info parsing, so we throw an error - otherwise just fallback to default
throw Error('[@nextcloud/eslint-plugin] AppInfo parsing was enabled, but no `appinfo/info.xml` was found.')
}
}

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

0 comments on commit 2185b62

Please sign in to comment.