Skip to content

Commit 5417c1b

Browse files
authored
Guard against similar package names in renamed-package-scope ESLint rule (#2732)
1 parent 9291d65 commit 5417c1b

File tree

7 files changed

+15
-5
lines changed

7 files changed

+15
-5
lines changed

.changeset/shaggy-tomatoes-protect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sumup-oss/eslint-plugin-circuit-ui": patch
3+
---
4+
5+
Guarded against similar names package names in the `renamed-package-scope` ESLint rule.

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ jobs:
3434
run: npm run lint:css
3535

3636
- name: Run unit tests
37-
run: npm run test:ci
37+
# For some reason, the global script doesn't run tests in packages/eslint-plugin-circuit-ui
38+
# I suspect it's because it's not an ES module.
39+
run: npm run test:ci && cd packages/eslint-plugin-circuit-ui && npm run test:ci
3840

3941
- name: Upload results to Codecov
4042
uses: codecov/codecov-action@v4

packages/eslint-plugin-circuit-ui/component-lifecycle-imports/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ ruleTester.run('component-lifecycle-imports', componentLifecycleImports, {
113113
{
114114
name: '[Experimental] single import with single match',
115115
code: `
116-
import { Calendar } from '@sumup/circuit-ui/experimental';
116+
import { Calendar } from '@sumup-oss/circuit-ui/experimental';
117117
`,
118118
output: `
119-
import { Calendar } from '@sumup/circuit-ui';
119+
import { Calendar } from '@sumup-oss/circuit-ui';
120120
`,
121121
errors: [{ messageId: 'refactor' }],
122122
},

packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const configs: (Config & { components: string[] })[] = [
7373
{
7474
type: 'values',
7575
components: ['Badge', 'NotificationInline', 'NotificationToast'],
76+
hook: 'setToast',
7677
prop: 'variant',
7778
values: {
7879
confirm: 'success',

packages/eslint-plugin-circuit-ui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"homepage": "https://github.com/sumup-oss/circuit-ui/tree/main/packages/eslint-plugin-circuit-ui/README.md",
2525
"scripts": {
2626
"build": "tsc",
27-
"test": "vitest"
27+
"test": "vitest",
28+
"test:ci": "vitest --coverage"
2829
},
2930
"dependencies": {
3031
"@typescript-eslint/utils": "^7.16.1"

packages/eslint-plugin-circuit-ui/renamed-package-scope/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ ruleTester.run('renamed-package-scope', renamedPackageScope, {
3737
name: 'import from an unaffected @sumup package',
3838
code: `
3939
import { OIDCClient } from '@sumup/nanoauth';
40+
import { FormDataType } from '@sumup/circuit-ui-form';
4041
`,
4142
},
4243
{

packages/eslint-plugin-circuit-ui/renamed-package-scope/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const renamedPackageScope = createRule({
6767
const escapedFrom = from.replace('/', '\\u002F');
6868

6969
return Object.assign(visitors, {
70-
[`ImportDeclaration:has(Literal[value=/${escapedFrom}.*/])`]: (
70+
[`ImportDeclaration:has(Literal[value=/${escapedFrom}(?!-).*/])`]: (
7171
node: TSESTree.ImportDeclaration,
7272
) => {
7373
context.report({

0 commit comments

Comments
 (0)