@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
44import type { Linter } from 'eslint'
55import eslint from '@eslint/js'
66import astroPlugin from 'eslint-plugin-astro'
7- import importPlugin from 'eslint-plugin-import'
7+ import importLitePlugin from 'eslint-plugin-import-lite '
88import jsdocPlugin from 'eslint-plugin-jsdoc'
99import securityPlugin from 'eslint-plugin-security'
1010import ymlPlugin from 'eslint-plugin-yml'
@@ -23,8 +23,7 @@ export default [
2323 eslint . configs . recommended ,
2424 ...tsPlugin . configs . recommended ,
2525 ...astroPlugin . configs . recommended ,
26- ...astroPlugin . configs [ 'jsx-a11y-strict' ] ,
27- importPlugin . flatConfigs . recommended ,
26+ importLitePlugin . configs . recommended ,
2827 jsdocPlugin . configs [ 'flat/recommended-typescript' ] ,
2928 securityPlugin . configs . recommended ,
3029 ...ymlPlugin . configs [ 'flat/recommended' ] ,
@@ -38,15 +37,6 @@ export default [
3837 } ,
3938 } ,
4039 } ,
41- settings : {
42- 'import/resolver' : {
43- typescript : {
44- alwaysTryTypes : true ,
45- project : './tsconfig.json' ,
46- extensions : [ '.ts' , '.tsx' , '.astro' , '.d.ts' , '.js' , '.mjs' , '.cjs' ] ,
47- } ,
48- } ,
49- } ,
5040 languageOptions : {
5141 ecmaVersion : 'latest' ,
5242 sourceType : 'module' ,
@@ -93,33 +83,7 @@ export default [
9383 'arrow-body-style' : 'off' ,
9484 'camelcase' : [ level ] ,
9585 'curly' : 'off' ,
96- 'import/no-unresolved' : [
97- level ,
98- {
99- ignore : [
100- '^astro:.*' , // Ignore Astro virtual modules
101- '^virtual:pwa-register$' ,
102- '^\\./.*' , // Ignore relative imports (let TypeScript handle these)
103- ] ,
104- } ,
105- ] ,
106- 'import/no-webpack-loader-syntax' : level ,
107- 'import/extensions' : [
108- level ,
109- 'ignorePackages' , // Ignores extensions for packages
110- {
111- 'js' : 'never' ,
112- 'jsx' : 'always' ,
113- 'ts' : 'never' ,
114- 'tsx' : 'always' ,
115- 'mjs' : 'always' ,
116- 'cjs' : 'always' ,
117- 'astro' : 'always' ,
118- 'json' : 'always' ,
119- 'svg' : 'always' ,
120- } ,
121- ] ,
122- 'import/order' : 'off' ,
86+ 'import-lite/no-duplicates' : level ,
12387 'jsdoc/check-indentation' : level ,
12488 'jsdoc/check-line-alignment' : 'off' ,
12589 'jsdoc/check-param-names' : 'off' ,
@@ -165,19 +129,6 @@ export default [
165129 'semi' : [ 'error' , 'never' ] ,
166130 } ,
167131 } ,
168- {
169- files : [ '**/*.astro' ] ,
170- rules : {
171- 'import/extensions' : 'off' ,
172- } ,
173- } ,
174- {
175- files : [ '**/*.astro/*.js' , '**/*.astro/*.ts' , '**/*.astro/*.tsx' ] ,
176- rules : {
177- 'import/extensions' : 'off' ,
178- } ,
179- } ,
180-
181132 /**
182133 * =================================================================================================
183134 *
@@ -587,128 +538,90 @@ export default [
587538 */
588539 {
589540 files : [
590- '**/*.astro' ,
591- '**/*.ts' ,
592- '**/*.tsx' ,
541+ 'src/**/client/**/*.{astro,ts,tsx}' ,
542+ ] ,
543+ ignores : [
544+ 'src/pages/api/_environment/environmentApi.ts' ,
545+ 'src/pages/api/_logger/index.ts' ,
593546 ] ,
594547 rules : {
595- 'import/ no-restricted-paths ' : [
548+ 'no-restricted-imports ' : [
596549 level ,
597550 {
598- zones : [
551+ patterns : [
599552 {
600- target : 'src/**/client/**/*' ,
601- from : 'src/lib/**/*' ,
553+ group : [ 'src/lib/**/*' , '@lib/**/*' ] ,
602554 message : 'The src/lib directory is for build-time code only.' ,
603555 } ,
604556 ] ,
605557 } ,
606558 ] ,
607559 } ,
608560 } ,
609- {
610- files : [
611- '**/*.astro' ,
612- '**/*.ts' ,
613- '**/*.tsx' ,
614- ] ,
615- rules : {
616- 'import/no-restricted-paths' : [
617- 'off' ,
618- {
619- zones : [
620- {
621- target : 'src/**/server/**/*' ,
622- from : 'src/lib/**/*' ,
623- } ,
624- ] ,
625- } ,
626- ] ,
627- } ,
628- } ,
629561 /**
630562 * Restrict the client directory in components, layouts, and pages to importing only from src/lib
631563 */
632564 {
633565 files : [
634- '**/*.astro' ,
635- '**/*.ts' ,
636- '**/*.tsx' ,
566+ 'src/**/server/**/*.{astro,ts,tsx}' ,
567+ ] ,
568+ ignores : [
569+ 'src/pages/api/_environment/environmentApi.ts' ,
570+ 'src/pages/api/_logger/index.ts' ,
637571 ] ,
638572 rules : {
639- 'import/ no-restricted-paths ' : [
573+ 'no-restricted-imports ' : [
640574 level ,
641575 {
642- zones : [
576+ patterns : [
643577 {
644- target : 'src/**/server/**/*' ,
645- from : 'src/components/scripts/**/*' ,
578+ group : [
579+ 'src/components/scripts/**/*' ,
580+ '@components/scripts/**/*' ,
581+ ] ,
646582 message : 'The src/components/scripts directory is for client bundle code only.' ,
647583 } ,
648584 ] ,
649585 } ,
650586 ] ,
651587 } ,
652588 } ,
653- {
654- files : [
655- '**/*.astro' ,
656- '**/*.ts' ,
657- '**/*.tsx' ,
658- ] ,
659- rules : {
660- 'import/no-restricted-paths' : [
661- 'off' ,
662- {
663- zones : [
664- {
665- target : 'src/**/client/**/*' ,
666- from : 'src/components/scripts/**/*' ,
667- } ,
668- ] ,
669- } ,
670- ] ,
671- } ,
672- } ,
673589 /**
674590 * Test files can import from server code in src/lib, but must use server-side helpers
675591 */
676592 {
677593 files : [
678594 'src/**/__tests__/**/*'
679595 ] ,
596+ ignores : [
597+ 'src/components/scripts/utils/__tests__/siteUrlClient.spec.ts' ,
598+ ] ,
680599 rules : {
681- 'import/ no-restricted-paths ' : [
600+ 'no-restricted-imports ' : [
682601 level ,
683602 {
684- zones : [
603+ paths : [
604+ {
605+ name : 'src/components/scripts/utils/environmentClient.ts' ,
606+ message : 'use src/lib/config/environmentServer.ts in test files, not environmentClient.' ,
607+ } ,
685608 {
686- target : 'src/**/__tests__/**/*' ,
687- from : 'src/components/scripts/utils/environmentClient.ts' ,
609+ name : '@components/scripts/utils/environmentClient' ,
688610 message : 'use src/lib/config/environmentServer.ts in test files, not environmentClient.' ,
689611 } ,
690612 {
691- target : 'src/**/__tests__/**/*' ,
692- from : 'src/components/scripts/utils/siteUrlClient.ts' ,
613+ name : 'src/components/scripts/utils/siteUrlClient.ts' ,
614+ message : 'use src/lib/config/siteUrlServer.ts in test files, not siteUrlClient.' ,
615+ } ,
616+ {
617+ name : '@components/scripts/utils/siteUrlClient' ,
693618 message : 'use src/lib/config/siteUrlServer.ts in test files, not siteUrlClient.' ,
694619 } ,
695620 ] ,
696621 } ,
697622 ] ,
698623 } ,
699624 } ,
700- {
701- files : [
702- /** Test case for the utility is an exception to the restricted paths rule */
703- 'src/components/scripts/utils/__tests__/siteUrlClient.spec.ts' ,
704- /** Environment file in src/pages/api is an exception to the restricted paths rule */
705- 'src/pages/api/_environment/environmentApi.ts' ,
706- 'src/pages/api/_logger/index.ts' ,
707- ] ,
708- rules : {
709- 'import/no-restricted-paths' : 'off' ,
710- } ,
711- } ,
712625
713626 /**
714627 * =================================================================================================
@@ -903,14 +816,6 @@ export default [
903816 'test/e2e/specs/14-system/package-release.spec.ts' ,
904817 'test/e2e/specs/14-system/privacy-policy-version.spec.ts' ,
905818 ] ,
906- rules : {
907- 'import/extensions' : 'off' ,
908- } ,
909- } ,
910- {
911- files : [ '**/*.astro' ] ,
912- rules : {
913- 'import/extensions' : 'off' ,
914- } ,
819+ rules : { } ,
915820 } ,
916821]
0 commit comments