Skip to content
Merged

Next #64

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 84 additions & 114 deletions bun.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/eslint-plugin-markdown": "^2.0.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "^4.0.3",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jsonc": "^2.21.0",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-prettier": "^5.5.4",
"husky": "^9.1.7",
"npm-check-updates": "^19.1.1",
"prettier": "^3.6.2",
"semantic-release": "^25.0.0",
"vitest": "^3.2.4"
"semantic-release": "^25.0.1",
"vitest": "^4.0.3"
},
"dependencies": {
"@eslint/js": "^9.37.0",
"@eslint/js": "^9.38.0",
"@vue/compiler-sfc": "^3.5.22",
"eslint": "^9.37.0",
"eslint": "^9.38.0",
"minimatch": "^10.0.3",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.1",
"typescript-eslint": "^8.46.2",
"vue-eslint-parser": "^10.2.0"
}
}
6 changes: 2 additions & 4 deletions src/rules/sfc-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ export const sfcOrder = createRule<VueModularRuleModule>({
if (descriptor.template) blocks.push({ type: 'template', pos: descriptor.template.loc.start.offset })

// styles (multiple)
if (Array.isArray(descriptor.styles)) {
for (const s of descriptor.styles) {
blocks.push({ type: 'style', pos: s.loc.start.offset })
}
for (const s of descriptor.styles) {
blocks.push({ type: 'style', pos: s.loc.start.offset })
}

// Sort by position to get actual order
Expand Down
5 changes: 5 additions & 0 deletions tests/rules/app-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('app-imports', () => {
filename: 'src/app/router.ts',
errors: [{ messageId: 'forbiddenImport', data: { file: 'src/app/router.ts', target: '@/lib/some' } }],
},
{
code: "import m from '@/features/auth/someFile'",
filename: 'src/app/main.ts',
errors: [{ messageId: 'forbiddenImport', data: { file: 'src/app/main.ts', target: '@/features/auth/someFile' } }],
},
],
})
})
Expand Down
8 changes: 8 additions & 0 deletions tests/rules/cross-imports-alias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('cross-imports-alias', () => {
{ code: `import { config } from '@/shared/config'`, filename: 'src/shared/components/Input.vue' },
// direct shared to shared with relative path
{ code: `import { helper } from './helper'`, filename: 'src/shared/services/api.ts' },
// alias import across features (allowed)
{ code: `import other from '@/features/payments/utils'`, filename: 'src/features/auth/Login.ts' },
],
invalid: [
// feature -> another feature using non-alias absolute path
Expand All @@ -54,6 +56,12 @@ describe('cross-imports-alias', () => {
filename: 'src/shared/lib/file.ts',
errors: [{ messageId: 'useAlias' }],
},
// non-aliased absolute import from one feature to another should be reported
{
code: `import stuff from '/src/features/payments/utils'`,
filename: 'src/features/auth/Login.ts',
errors: [{ messageId: 'useAlias' }],
},
],
})
})
Expand Down
6 changes: 6 additions & 0 deletions tests/rules/sfc-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ describe('sfc-order', () => {
options: [{ order: ['script', 'template', 'style'] }],
errors: [{ messageId: 'wrongOrder' }],
},
// both <script> and <script setup> present, wrong order
{
code: '<template><div/></template><script>const a = 1</script><script setup>const b = 2</script><style>body{}</style>',
filename: 'src/components/BothScriptWrong.vue',
errors: [{ messageId: 'wrongOrder' }],
},
],
})
})
Expand Down
5 changes: 5 additions & 0 deletions tests/rules/shared-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ describe('shared-imports', () => {
code: `import { util } from '@/shared/utils'`,
filename: 'src/shared/lib/util.ts',
},
// export from shared (should be allowed) - covers ExportAllDeclaration branch where resolvedPath is inside sharedPath
{
code: `export * from '@/shared/helpers'`,
filename: 'src/shared/lib/util.ts',
},
// external imports are ignored
{
code: `import external from 'left-pad'`,
Expand Down