Skip to content

Commit

Permalink
Merge pull request #185 from nextcloud-libraries/fix/relax-defaults
Browse files Browse the repository at this point in the history
fix: Relax recommended config to work also with libraries
  • Loading branch information
Pytal committed Apr 15, 2024
2 parents 957d471 + 2185b62 commit abbe580
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 abbe580

Please sign in to comment.