Skip to content

Commit 60bb082

Browse files
authored
Merge pull request #1452 from nextcloud-libraries/fix/1001/adjust-rules
fix: adjust existing rules
2 parents 072e380 + fc631db commit 60bb082

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

lib/plugins/nextcloud/rules/no-deprecated-library-exports.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ describe('no-deprecated-library-exports', () => {
105105
{
106106
code: '<script>import isMobile from \'@nextcloud/vue/dist/Mixins/isMobile.js\'</script>',
107107
filename: '/a/src/component.vue',
108-
errors: [{ messageId: 'deprecatedDist' }],
109-
output: '<script>import isMobile from \'@nextcloud/vue/mixins/isMobile\'</script>',
108+
errors: [{ messageId: 'deprecatedMixin' }],
110109
},
111110
],
112111
})

lib/plugins/nextcloud/rules/no-deprecated-library-exports.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ const rule: Rule.RuleModule = {
3232
const isVersionValidForDist = versionSatisfies('8.23.0')
3333

3434
const oldPattern = '@nextcloud/vue/dist/([^/]+)/([^/.]+)'
35-
const mixinPattern = '@nextcloud/vue/mixins/([^/.]+)'
35+
// Matches both the legacy `dist/Mixins/*` path and a bare `mixins/*` path.
36+
// There is no clean `@nextcloud/vue/mixins/*` subpath export (only components,
37+
// composables, directives and functions), so mixins must be migrated to
38+
// composables rather than have their import path rewritten.
39+
const mixinPattern = '@nextcloud/vue/(?:dist/)?mixins/([^/.]+)'
3640

3741
const isVersionValidForTooltip = versionSatisfies('8.25.0')
3842
const tooltipPattern = '@nextcloud/vue/directives/Tooltip'
@@ -91,6 +95,11 @@ const rule: Rule.RuleModule = {
9195
return
9296
}
9397

98+
// Mixins removed in v9 and already reported as `deprecatedMixin`
99+
if (match[1].toLowerCase() === 'mixins') {
100+
return
101+
}
102+
94103
const newImportPath = `'@nextcloud/vue/${match[1].toLowerCase()}/${match[2]}'`
95104
context.report({
96105
node,

lib/plugins/nextcloud/rules/no-deprecated-library-props.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default {
3333
useNoFocusTrapInstead: 'Using `focus-trap` is deprecated - use `no-focus-trap` instead',
3434
useKeepOpenInstead: 'Using `close-on-select` is deprecated - use `keep-open` instead',
3535
useNcSelectUsersInstead: 'Using `user-select` is deprecated - use `NcSelectUsers` component instead',
36-
useArrowEndInstead: 'Using `arrow-right` is deprecated - use `arrow-end` instead',
36+
useArrowEndInstead: 'Using `arrowRight` as `trailing-button-icon` value is deprecated - use `arrowEnd` instead',
3737
removeAriaHidden: 'Using `aria-hidden` is deprecated - remove prop from components, otherwise root element will inherit incorrect attribute.',
3838
removeLimitWidth: 'Using `limit-width` is deprecated - remove prop from components, otherwise root element will inherit incorrect attribute.',
3939
removeExact: 'Using `exact` is deprecated - consult Vue Router documentation for alternatives.',
@@ -54,7 +54,7 @@ export default {
5454
const isDateTimePickerFormatValid = versionSatisfies('8.25.0') // #6738
5555
const isNcSelectKeepOpenValid = versionSatisfies('8.25.0') // #6791
5656
const isNcPopoverNoFocusTrapValid = versionSatisfies('8.26.0') // #6808
57-
const isNcSelectUsersValid = versionSatisfies('8.27.1') // #7032
57+
const isNcSelectUsersValid = versionSatisfies('8.25.0') // #6791
5858
const isNcTextFieldArrowEndValid = versionSatisfies('8.28.0') // #7002
5959
const isCloseButtonOutsideValid = versionSatisfies('8.32.0') // #7553
6060

@@ -374,7 +374,7 @@ export default {
374374
},
375375

376376
'VElement[name="ncsettingssection"] VAttribute:has(VIdentifier[name="limit-width"])': function(node: AST.VAttribute | AST.VDirective) {
377-
// This was deprecated in 8.13.0 (Nextcloud 30+), before first supported version by plugin
377+
// This was deprecated in 8.12.0 (Nextcloud 30+), before first supported version by plugin
378378
context.report({
379379
node,
380380
messageId: 'removeLimitWidth',

lib/plugins/nextcloud/utils/lib-version-parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ export function createLibVersionValidator({ cwd, physicalFilename }, importResol
3737
return () => false
3838
}
3939

40-
if (!cachedMap[packageJsonDir]) {
40+
if (!cachedMap.has(packageJsonDir)) {
4141
const json = JSON.parse(readFileSync(join(packageJsonDir, 'package.json'), 'utf-8'))
4242
const libVersion = json.version
43-
cachedMap[packageJsonDir] = (version: string) => gte(libVersion, version)
43+
cachedMap.set(packageJsonDir, (version: string) => gte(libVersion, version))
4444
}
4545

46-
return cachedMap[packageJsonDir]
46+
return cachedMap.get(packageJsonDir)!
4747
}
4848

4949
/**

0 commit comments

Comments
 (0)