Skip to content

Commit

Permalink
Guard against similar package names in renamed-package-scope ESLint r…
Browse files Browse the repository at this point in the history
…ule (#2732)
  • Loading branch information
connor-baer authored Oct 22, 2024
1 parent 9291d65 commit 5417c1b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-tomatoes-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup-oss/eslint-plugin-circuit-ui": patch
---

Guarded against similar names package names in the `renamed-package-scope` ESLint rule.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' }],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const configs: (Config & { components: string[] })[] = [
{
type: 'values',
components: ['Badge', 'NotificationInline', 'NotificationToast'],
hook: 'setToast',
prop: 'variant',
values: {
confirm: 'success',
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-circuit-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
`,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 5417c1b

Please sign in to comment.