@xsynaptic/eslint-config 3.6.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
# ESLint Config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A shared ESLint config factory for several Astro projects. It is not intended for public consumption.
|
|
4
|
+
|
|
5
|
+
## Astro
|
|
6
|
+
|
|
7
|
+
`getAstroConfig()` provides the Astro plugin rules and the `.astro` parser wiring. Two of its features resolve plugins from the consuming project's root (via `process.cwd()`), so those plugins must be installed there directly and cannot be relied on transitively:
|
|
8
|
+
|
|
9
|
+
- **Accessibility**: install `eslint-plugin-jsx-a11y` and pass a config, e.g. `getAstroConfig({ a11y: astroPlugin.configs['flat/jsx-a11y-strict'] })`.
|
|
10
|
+
- **TypeScript in `<script>` tags**: install `@typescript-eslint/parser`. eslint-plugin-astro uses it to lint `<script>` blocks, and that linting silently degrades if it is absent.
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import eslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
1
2
|
import { defineConfig } from "@eslint/config-helpers";
|
|
2
3
|
import eslint from "@eslint/js";
|
|
3
4
|
import astroPlugin from "eslint-plugin-astro";
|
|
@@ -86,7 +87,11 @@ function getConfig(customConfig, options) {
|
|
|
86
87
|
"unicorn/number-literal-case": ["error", { hexadecimalValue: "lowercase" }],
|
|
87
88
|
"unicorn/prevent-abbreviations": "off"
|
|
88
89
|
} },
|
|
89
|
-
perfectionist.configs["recommended-natural"]
|
|
90
|
+
perfectionist.configs["recommended-natural"],
|
|
91
|
+
{
|
|
92
|
+
plugins: { "@eslint-community/eslint-comments": eslintComments },
|
|
93
|
+
rules: { "@eslint-community/eslint-comments/require-description": ["error", { ignore: ["eslint-enable"] }] }
|
|
94
|
+
}
|
|
90
95
|
], ...customConfig ?? []);
|
|
91
96
|
}
|
|
92
97
|
function getWebComponentConfig(files) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["webComponentConfigs"],"sources":["../src/index.ts"],"sourcesContent":["import type { Config, ConfigWithExtends, ConfigWithExtendsArray } from '@eslint/config-helpers';\n\nimport { defineConfig } from '@eslint/config-helpers';\nimport eslint from '@eslint/js';\nimport astroPlugin from 'eslint-plugin-astro';\nimport perfectionist from 'eslint-plugin-perfectionist';\nimport unicornPlugin from 'eslint-plugin-unicorn';\nimport { configs as webComponentConfigs } from 'eslint-plugin-wc';\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\n\ntype RestrictedSyntaxOption = string | { message?: string; selector: string };\n\n// Extend via `getConfig(_, { restrictedSyntax })`\n// Redefining the rule clobbers these, as ESLint replaces rule keys wholesale\nexport const restrictedSyntaxDefaults: Array<RestrictedSyntaxOption> = [\n\t{\n\t\tmessage: 'Separate type imports into their own `import type` statement.',\n\t\tselector: 'ImportDeclaration[importKind=\"value\"] ImportSpecifier[importKind=\"type\"]',\n\t},\n\t{\n\t\tmessage:\n\t\t\t'Use a ternary returning undefined (condition ? <Element /> : undefined) instead of && for conditional rendering.',\n\t\tselector:\n\t\t\t':matches(JSXElement, JSXFragment) > JSXExpressionContainer > LogicalExpression[operator=\"&&\"]',\n\t},\n];\n\n// Astro plugin rules plus the `.astro` parser wiring and disableTypeChecked blocks it needs\n// Types can't resolve through the Astro parser so `astro check` owns type checking\n// For a11y, install eslint-plugin-jsx-a11y and pass a config (e.g. `astroPlugin.configs['flat/jsx-a11y-strict']`)\nexport function getAstroConfig(options?: {\n\ta11y?: ConfigWithExtendsArray;\n}): ConfigWithExtendsArray {\n\treturn [\n\t\t...astroPlugin.configs['flat/recommended'],\n\t\t...(options?.a11y ?? []),\n\t\t// Split from the disableTypeChecked block below so it doesn't clobber these parserOptions\n\t\t{\n\t\t\tfiles: ['**/*.astro'],\n\t\t\tlanguageOptions: {\n\t\t\t\tparserOptions: {\n\t\t\t\t\textraFileExtensions: ['.astro'],\n\t\t\t\t\tparser: tseslint.parser,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.astro'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.astro/*.ts', '*.astro/*.ts'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.js', '**/*.mjs', '**/*.cjs'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t];\n}\n\nexport function getConfig(\n\tcustomConfig?: ConfigWithExtendsArray,\n\toptions?: {\n\t\tcustomGlobals?: Record<string, 'readonly' | 'writeable'>;\n\t\tparserOptions?: NonNullable<Config['languageOptions']>['parserOptions'];\n\t\trestrictedSyntax?: Array<RestrictedSyntaxOption>;\n\t},\n): ConfigWithExtendsArray {\n\tconst customGlobals = options?.customGlobals ?? {};\n\tconst restrictedSyntax = [...restrictedSyntaxDefaults, ...(options?.restrictedSyntax ?? [])];\n\n\tconst baseConfig = [\n\t\teslint.configs.recommended,\n\t\t...tseslint.configs.strictTypeChecked,\n\t\t...tseslint.configs.stylisticTypeChecked,\n\t\t{\n\t\t\tlanguageOptions: {\n\t\t\t\tglobals: {\n\t\t\t\t\t...globals.builtin,\n\t\t\t\t\t...globals.nodeBuiltin,\n\t\t\t\t\t...customGlobals,\n\t\t\t\t},\n\t\t\t\tparser: tseslint.parser,\n\t\t\t\tparserOptions: options?.parserOptions ?? {\n\t\t\t\t\tprojectService: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\t'@typescript-eslint': tseslint.plugin,\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t'@typescript-eslint/array-type': ['warn', { default: 'generic' }],\n\t\t\t\t'@typescript-eslint/consistent-type-imports': [\n\t\t\t\t\t'error',\n\t\t\t\t\t{ fixStyle: 'separate-type-imports', prefer: 'type-imports' },\n\t\t\t\t],\n\t\t\t\t'@typescript-eslint/no-non-null-assertion': 'off',\n\t\t\t\t'@typescript-eslint/no-unused-vars': [\n\t\t\t\t\t'error',\n\t\t\t\t\t{\n\t\t\t\t\t\targsIgnorePattern: '^_',\n\t\t\t\t\t\tcaughtErrorsIgnorePattern: '^_',\n\t\t\t\t\t\tdestructuredArrayIgnorePattern: '^_',\n\t\t\t\t\t\tignoreRestSiblings: true,\n\t\t\t\t\t\tvarsIgnorePattern: '^_',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\t'@typescript-eslint/prefer-nullish-coalescing': 'off',\n\t\t\t\t'no-restricted-syntax': ['error', ...restrictedSyntax],\n\t\t\t},\n\t\t},\n\t\tunicornPlugin.configs.recommended,\n\t\t{\n\t\t\trules: {\n\t\t\t\t'unicorn/filename-case': 'warn',\n\t\t\t\t'unicorn/no-array-callback-reference': 'off', // I prefer this pattern for filtering/sorting content\n\t\t\t\t'unicorn/number-literal-case': ['error', { hexadecimalValue: 'lowercase' }], // Lowercase hex to match Prettier\n\t\t\t\t'unicorn/prevent-abbreviations': 'off', // I *like* abbreviations!\n\t\t\t},\n\t\t},\n\t\tperfectionist.configs['recommended-natural'],\n\t] satisfies Array<ConfigWithExtends>;\n\n\treturn defineConfig(...baseConfig, ...(customConfig ?? []));\n}\n\n// Opt-in rules for authoring native web components\nexport function getWebComponentConfig(files: Array<string>): ConfigWithExtends {\n\tconst bestPractice = webComponentConfigs['flat/best-practice'];\n\n\treturn {\n\t\t...bestPractice,\n\t\tfiles,\n\t\trules: {\n\t\t\t...bestPractice?.rules,\n\t\t\t'wc/define-tag-after-class-definition': 'error',\n\t\t\t'wc/guard-define-call': 'error',\n\t\t\t'wc/max-elements-per-file': 'error',\n\t\t\t'wc/no-child-traversal-in-connectedcallback': 'off',\n\t\t\t'wc/no-constructor': 'error',\n\t\t\t'wc/no-exports-with-element': 'error',\n\t\t\t'wc/no-method-prefixed-with-on': 'error',\n\t\t},\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["webComponentConfigs"],"sources":["../src/index.ts"],"sourcesContent":["import type { Config, ConfigWithExtends, ConfigWithExtendsArray } from '@eslint/config-helpers';\n\nimport eslintComments from '@eslint-community/eslint-plugin-eslint-comments';\nimport { defineConfig } from '@eslint/config-helpers';\nimport eslint from '@eslint/js';\nimport astroPlugin from 'eslint-plugin-astro';\nimport perfectionist from 'eslint-plugin-perfectionist';\nimport unicornPlugin from 'eslint-plugin-unicorn';\nimport { configs as webComponentConfigs } from 'eslint-plugin-wc';\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\n\ntype RestrictedSyntaxOption = string | { message?: string; selector: string };\n\n// Extend via `getConfig(_, { restrictedSyntax })`\n// Redefining the rule clobbers these, as ESLint replaces rule keys wholesale\nexport const restrictedSyntaxDefaults: Array<RestrictedSyntaxOption> = [\n\t{\n\t\tmessage: 'Separate type imports into their own `import type` statement.',\n\t\tselector: 'ImportDeclaration[importKind=\"value\"] ImportSpecifier[importKind=\"type\"]',\n\t},\n\t{\n\t\tmessage:\n\t\t\t'Use a ternary returning undefined (condition ? <Element /> : undefined) instead of && for conditional rendering.',\n\t\tselector:\n\t\t\t':matches(JSXElement, JSXFragment) > JSXExpressionContainer > LogicalExpression[operator=\"&&\"]',\n\t},\n];\n\n// Astro plugin rules plus the `.astro` parser wiring and disableTypeChecked blocks it needs\n// Types can't resolve through the Astro parser so `astro check` owns type checking\n// For a11y, install eslint-plugin-jsx-a11y and pass a config (e.g. `astroPlugin.configs['flat/jsx-a11y-strict']`)\nexport function getAstroConfig(options?: {\n\ta11y?: ConfigWithExtendsArray;\n}): ConfigWithExtendsArray {\n\treturn [\n\t\t...astroPlugin.configs['flat/recommended'],\n\t\t...(options?.a11y ?? []),\n\t\t// Split from the disableTypeChecked block below so it doesn't clobber these parserOptions\n\t\t{\n\t\t\tfiles: ['**/*.astro'],\n\t\t\tlanguageOptions: {\n\t\t\t\tparserOptions: {\n\t\t\t\t\textraFileExtensions: ['.astro'],\n\t\t\t\t\tparser: tseslint.parser,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.astro'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.astro/*.ts', '*.astro/*.ts'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t\t{\n\t\t\tfiles: ['**/*.js', '**/*.mjs', '**/*.cjs'],\n\t\t\t...tseslint.configs.disableTypeChecked,\n\t\t},\n\t];\n}\n\nexport function getConfig(\n\tcustomConfig?: ConfigWithExtendsArray,\n\toptions?: {\n\t\tcustomGlobals?: Record<string, 'readonly' | 'writeable'>;\n\t\tparserOptions?: NonNullable<Config['languageOptions']>['parserOptions'];\n\t\trestrictedSyntax?: Array<RestrictedSyntaxOption>;\n\t},\n): ConfigWithExtendsArray {\n\tconst customGlobals = options?.customGlobals ?? {};\n\tconst restrictedSyntax = [...restrictedSyntaxDefaults, ...(options?.restrictedSyntax ?? [])];\n\n\tconst baseConfig = [\n\t\teslint.configs.recommended,\n\t\t...tseslint.configs.strictTypeChecked,\n\t\t...tseslint.configs.stylisticTypeChecked,\n\t\t{\n\t\t\tlanguageOptions: {\n\t\t\t\tglobals: {\n\t\t\t\t\t...globals.builtin,\n\t\t\t\t\t...globals.nodeBuiltin,\n\t\t\t\t\t...customGlobals,\n\t\t\t\t},\n\t\t\t\tparser: tseslint.parser,\n\t\t\t\tparserOptions: options?.parserOptions ?? {\n\t\t\t\t\tprojectService: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\t'@typescript-eslint': tseslint.plugin,\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t'@typescript-eslint/array-type': ['warn', { default: 'generic' }],\n\t\t\t\t'@typescript-eslint/consistent-type-imports': [\n\t\t\t\t\t'error',\n\t\t\t\t\t{ fixStyle: 'separate-type-imports', prefer: 'type-imports' },\n\t\t\t\t],\n\t\t\t\t'@typescript-eslint/no-non-null-assertion': 'off',\n\t\t\t\t'@typescript-eslint/no-unused-vars': [\n\t\t\t\t\t'error',\n\t\t\t\t\t{\n\t\t\t\t\t\targsIgnorePattern: '^_',\n\t\t\t\t\t\tcaughtErrorsIgnorePattern: '^_',\n\t\t\t\t\t\tdestructuredArrayIgnorePattern: '^_',\n\t\t\t\t\t\tignoreRestSiblings: true,\n\t\t\t\t\t\tvarsIgnorePattern: '^_',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\t'@typescript-eslint/prefer-nullish-coalescing': 'off',\n\t\t\t\t'no-restricted-syntax': ['error', ...restrictedSyntax],\n\t\t\t},\n\t\t},\n\t\tunicornPlugin.configs.recommended,\n\t\t{\n\t\t\trules: {\n\t\t\t\t'unicorn/filename-case': 'warn',\n\t\t\t\t'unicorn/no-array-callback-reference': 'off', // I prefer this pattern for filtering/sorting content\n\t\t\t\t'unicorn/number-literal-case': ['error', { hexadecimalValue: 'lowercase' }], // Lowercase hex to match Prettier\n\t\t\t\t'unicorn/prevent-abbreviations': 'off', // I *like* abbreviations!\n\t\t\t},\n\t\t},\n\t\tperfectionist.configs['recommended-natural'],\n\t\t{\n\t\t\tplugins: { '@eslint-community/eslint-comments': eslintComments },\n\t\t\trules: {\n\t\t\t\t'@eslint-community/eslint-comments/require-description': [\n\t\t\t\t\t'error',\n\t\t\t\t\t{ ignore: ['eslint-enable'] },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t] satisfies Array<ConfigWithExtends>;\n\n\treturn defineConfig(...baseConfig, ...(customConfig ?? []));\n}\n\n// Opt-in rules for authoring native web components\nexport function getWebComponentConfig(files: Array<string>): ConfigWithExtends {\n\tconst bestPractice = webComponentConfigs['flat/best-practice'];\n\n\treturn {\n\t\t...bestPractice,\n\t\tfiles,\n\t\trules: {\n\t\t\t...bestPractice?.rules,\n\t\t\t'wc/define-tag-after-class-definition': 'error',\n\t\t\t'wc/guard-define-call': 'error',\n\t\t\t'wc/max-elements-per-file': 'error',\n\t\t\t'wc/no-child-traversal-in-connectedcallback': 'off',\n\t\t\t'wc/no-constructor': 'error',\n\t\t\t'wc/no-exports-with-element': 'error',\n\t\t\t'wc/no-method-prefixed-with-on': 'error',\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,2BAA0D,CACtE;CACC,SAAS;CACT,UAAU;AACX,GACA;CACC,SACC;CACD,UACC;AACF,CACD;AAKA,SAAgB,eAAe,SAEJ;CAC1B,OAAO;EACN,GAAG,YAAY,QAAQ;EACvB,GAAI,SAAS,QAAQ,CAAC;EAEtB;GACC,OAAO,CAAC,YAAY;GACpB,iBAAiB,EAChB,eAAe;IACd,qBAAqB,CAAC,QAAQ;IAC9B,QAAQ,SAAS;GAClB,EACD;EACD;EACA;GACC,OAAO,CAAC,YAAY;GACpB,GAAG,SAAS,QAAQ;EACrB;EACA;GACC,OAAO,CAAC,mBAAmB,cAAc;GACzC,GAAG,SAAS,QAAQ;EACrB;EACA;GACC,OAAO;IAAC;IAAW;IAAY;GAAU;GACzC,GAAG,SAAS,QAAQ;EACrB;CACD;AACD;AAEA,SAAgB,UACf,cACA,SAKyB;CACzB,MAAM,gBAAgB,SAAS,iBAAiB,CAAC;CACjD,MAAM,mBAAmB,CAAC,GAAG,0BAA0B,GAAI,SAAS,oBAAoB,CAAC,CAAE;CA+D3F,OAAO,aAAa,GAAG;EA5DtB,OAAO,QAAQ;EACf,GAAG,SAAS,QAAQ;EACpB,GAAG,SAAS,QAAQ;EACpB;GACC,iBAAiB;IAChB,SAAS;KACR,GAAG,QAAQ;KACX,GAAG,QAAQ;KACX,GAAG;IACJ;IACA,QAAQ,SAAS;IACjB,eAAe,SAAS,iBAAiB,EACxC,gBAAgB,KACjB;GACD;GACA,SAAS,EACR,sBAAsB,SAAS,OAChC;GACA,OAAO;IACN,iCAAiC,CAAC,QAAQ,EAAE,SAAS,UAAU,CAAC;IAChE,8CAA8C,CAC7C,SACA;KAAE,UAAU;KAAyB,QAAQ;IAAe,CAC7D;IACA,4CAA4C;IAC5C,qCAAqC,CACpC,SACA;KACC,mBAAmB;KACnB,2BAA2B;KAC3B,gCAAgC;KAChC,oBAAoB;KACpB,mBAAmB;IACpB,CACD;IACA,gDAAgD;IAChD,wBAAwB,CAAC,SAAS,GAAG,gBAAgB;GACtD;EACD;EACA,cAAc,QAAQ;EACtB,EACC,OAAO;GACN,yBAAyB;GACzB,uCAAuC;GACvC,+BAA+B,CAAC,SAAS,EAAE,kBAAkB,YAAY,CAAC;GAC1E,iCAAiC;EAClC,EACD;EACA,cAAc,QAAQ;EACtB;GACC,SAAS,EAAE,qCAAqC,eAAe;GAC/D,OAAO,EACN,yDAAyD,CACxD,SACA,EAAE,QAAQ,CAAC,eAAe,EAAE,CAC7B,EACD;EACD;CAG+B,GAAG,GAAI,gBAAgB,CAAC,CAAE;AAC3D;AAGA,SAAgB,sBAAsB,OAAyC;CAC9E,MAAM,eAAeA,QAAoB;CAEzC,OAAO;EACN,GAAG;EACH;EACA,OAAO;GACN,GAAG,cAAc;GACjB,wCAAwC;GACxC,wBAAwB;GACxB,4BAA4B;GAC5B,8CAA8C;GAC9C,qBAAqB;GACrB,8BAA8B;GAC9B,iCAAiC;EAClC;CACD;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsynaptic/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "An ESLint config factory for TypeScript projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
],
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
|
|
35
36
|
"@eslint/config-helpers": "^0.6.0",
|
|
36
37
|
"@eslint/js": "^9.39.4",
|
|
37
38
|
"eslint-plugin-astro": "^1.7.0",
|
|
38
39
|
"eslint-plugin-perfectionist": "^5.9.0",
|
|
39
|
-
"eslint-plugin-unicorn": "^
|
|
40
|
+
"eslint-plugin-unicorn": "^65.0.1",
|
|
40
41
|
"eslint-plugin-wc": "^3.1.0",
|
|
41
42
|
"globals": "^17.6.0",
|
|
42
|
-
"typescript-eslint": "^8.
|
|
43
|
+
"typescript-eslint": "^8.61.0"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "tsdown",
|