diff --git a/.changeset/shaggy-tomatoes-protect.md b/.changeset/shaggy-tomatoes-protect.md new file mode 100644 index 0000000000..1ac4ecb0e8 --- /dev/null +++ b/.changeset/shaggy-tomatoes-protect.md @@ -0,0 +1,5 @@ +--- +"@sumup-oss/eslint-plugin-circuit-ui": patch +--- + +Guarded against similar names package names in the `renamed-package-scope` ESLint rule. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aab258516e..f3a10fd4a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,9 @@ jobs: run: npm run lint:css - name: Run unit tests - run: npm run test:ci + # For some reason, the global script doesn't run tests in packages/eslint-plugin-circuit-ui + # I suspect it's because it's not an ES module. + run: npm run test:ci && cd packages/eslint-plugin-circuit-ui && npm run test:ci - name: Upload results to Codecov uses: codecov/codecov-action@v4 diff --git a/packages/eslint-plugin-circuit-ui/component-lifecycle-imports/index.spec.ts b/packages/eslint-plugin-circuit-ui/component-lifecycle-imports/index.spec.ts index e3e2110e67..816c2ed056 100644 --- a/packages/eslint-plugin-circuit-ui/component-lifecycle-imports/index.spec.ts +++ b/packages/eslint-plugin-circuit-ui/component-lifecycle-imports/index.spec.ts @@ -113,10 +113,10 @@ ruleTester.run('component-lifecycle-imports', componentLifecycleImports, { { name: '[Experimental] single import with single match', code: ` - import { Calendar } from '@sumup/circuit-ui/experimental'; + import { Calendar } from '@sumup-oss/circuit-ui/experimental'; `, output: ` - import { Calendar } from '@sumup/circuit-ui'; + import { Calendar } from '@sumup-oss/circuit-ui'; `, errors: [{ messageId: 'refactor' }], }, diff --git a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts index b427c2d9fe..823911fd2c 100644 --- a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts +++ b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts @@ -73,6 +73,7 @@ const configs: (Config & { components: string[] })[] = [ { type: 'values', components: ['Badge', 'NotificationInline', 'NotificationToast'], + hook: 'setToast', prop: 'variant', values: { confirm: 'success', diff --git a/packages/eslint-plugin-circuit-ui/package.json b/packages/eslint-plugin-circuit-ui/package.json index 2916b9a719..1c2b14d74c 100644 --- a/packages/eslint-plugin-circuit-ui/package.json +++ b/packages/eslint-plugin-circuit-ui/package.json @@ -24,7 +24,8 @@ "homepage": "https://github.com/sumup-oss/circuit-ui/tree/main/packages/eslint-plugin-circuit-ui/README.md", "scripts": { "build": "tsc", - "test": "vitest" + "test": "vitest", + "test:ci": "vitest --coverage" }, "dependencies": { "@typescript-eslint/utils": "^7.16.1" diff --git a/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.spec.ts b/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.spec.ts index a2b4ba62c2..1bb11e3855 100644 --- a/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.spec.ts +++ b/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.spec.ts @@ -37,6 +37,7 @@ ruleTester.run('renamed-package-scope', renamedPackageScope, { name: 'import from an unaffected @sumup package', code: ` import { OIDCClient } from '@sumup/nanoauth'; + import { FormDataType } from '@sumup/circuit-ui-form'; `, }, { diff --git a/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.ts b/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.ts index 02d9c24892..e8693ffc52 100644 --- a/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.ts +++ b/packages/eslint-plugin-circuit-ui/renamed-package-scope/index.ts @@ -67,7 +67,7 @@ export const renamedPackageScope = createRule({ const escapedFrom = from.replace('/', '\\u002F'); return Object.assign(visitors, { - [`ImportDeclaration:has(Literal[value=/${escapedFrom}.*/])`]: ( + [`ImportDeclaration:has(Literal[value=/${escapedFrom}(?!-).*/])`]: ( node: TSESTree.ImportDeclaration, ) => { context.report({