@xsynaptic/eslint-config 2.0.1 → 3.0.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/.claude/settings.local.json +9 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -0
- package/eslint.config.ts +1 -1
- package/package.json +20 -9
- package/src/{get-config.ts → index.ts} +6 -5
- package/tsdown.config.ts +8 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as eslint0 from "eslint";
|
|
2
|
+
import { Config, ConfigWithExtendsArray } from "@eslint/config-helpers";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare function getConfig(customConfig?: ConfigWithExtendsArray, options?: {
|
|
6
|
+
customGlobals?: Record<string, "readonly" | "writeable">;
|
|
7
|
+
parserOptions?: NonNullable<Config["languageOptions"]>["parserOptions"];
|
|
8
|
+
}): eslint0.Linter.Config<eslint0.Linter.RulesRecord>[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@eslint/js";import t from"eslint-plugin-perfectionist";import n from"eslint-plugin-unicorn";import r from"globals";import i from"typescript-eslint";const a=[`env`,`extends`,`globals`,`ignorePatterns`,`noInlineConfig`,`overrides`,`parser`,`parserOptions`,`reportUnusedDisableDirectives`,`root`],o=new Set([`basePath`,`ignores`,`name`]);function s(e,t){return e.name?e.name:`UserConfig${t}`}function c(e,t){return typeof e==`string`?e:e.name?e.name:`ExtendedConfig${t}`}function l(e){for(let t of a)if(t in e)return!0;return!1}function u(e){return Object.keys(e).every(e=>o.has(e))}function d(e){let t=e.indexOf(`/`);if(t===-1)return{namespace:``,name:e};let n=e.slice(0,t);if(n[0]===`@`&&n!==`@`){let r=e.indexOf(`/`,t+1);if(r!==-1)return n=e.slice(0,r),{namespace:n,name:e.slice(r+1)}}let r=e.slice(t+1);return{namespace:n,name:r}}function f(e,t,n){let r=t.meta?.namespace;if(!r||r===e||!n.rules&&!n.processor&&!n.language)return n;let i={...n};if(i.rules){let t=Object.keys(i.rules),n={};for(let a=0;a<t.length;a++){let o=t[a],{namespace:s,name:c}=d(o);s===r?n[`${e}/${c}`]=i.rules[o]:n[o]=i.rules[o]}i.rules=n}if(typeof i.processor==`string`){let{namespace:t,name:n}=d(i.processor);t&&t===r&&(i.processor=`${e}/${n}`)}if(typeof i.language==`string`){let{namespace:t,name:n}=d(i.language);t===r&&(i.language=`${e}/${n}`)}return i}function p(e,t,n,r){if(Array.isArray(n))return n.map(n=>p(e,t,n,r));if(l(n))throw TypeError(`Plugin config "${r}" is an eslintrc config and cannot be used in this context.`);return f(e,t,n)}function m(e,t){let{namespace:n,name:r}=d(t),i=e.plugins?.[n];if(!i)throw TypeError(`Plugin "${n}" not found.`);let a=i.configs?.[r];if(a){if(Array.isArray(a)||!l(a))return p(n,i,a,t);let e=i.configs?.[`flat/${r}`];if(e&&(Array.isArray(e)||!l(e)))return p(n,i,e,t);throw TypeError(`Plugin config "${r}" in plugin "${n}" is an eslintrc config and cannot be used in this context.`)}throw TypeError(`Plugin config "${r}" not found in plugin "${n}".`)}function*h(e,t=``){for(let n=0;n<e.length;n++){let r=t?`${t}[${n}]`:`[${n}]`;if(Array.isArray(e[n])){yield*h(e[n],r);continue}yield{indexPath:r,value:e[n]}}}function g(e=[],t=[]){if(!t.length)return e.concat();if(!e.length)return t.concat();let n=[];for(let r of e)for(let e of t){let t=[];Array.isArray(r)?t.push(...r):t.push(r),Array.isArray(e)?t.push(...e):t.push(e),n.push(t)}return n}function _(e,t,n,r){let i={...n};return u(n)||(e.files&&(i.files=g(e.files,n.files)),e.ignores&&(i.ignores=e.ignores.concat(n.ignores??[]))),i.name=`${t} > ${r}`,e.basePath&&(i.basePath=e.basePath),i}function v(e,t){if(!e.extends)return[e];if(!Array.isArray(e.extends))throw TypeError("The `extends` property must be an array.");let{extends:n,...r}=e,i=new WeakMap,a=n.map(t=>{if(typeof t==`string`){let n=m(e,t);return Array.isArray(n)?n.forEach((e,n)=>{i.set(e,`${t}[${n}]`)}):i.set(n,t),n}return t}),o=[];for(let{indexPath:n,value:s}of h(a)){let a=s;if(`basePath`in a)throw TypeError("'basePath' in `extends` is not allowed.");if(`extends`in a)throw TypeError(`Nested 'extends' is not allowed.`);let l=t.get(e),u=i.get(s)??c(s,n);o.push(_(r,l,a,u))}return u(r)||o.push(r),o.flat()}function y(e,t){return e.flatMap(e=>v(e,t))}function b(...e){let t=new WeakMap,n=[];if(e.length===0)throw TypeError(`Expected one or more arguments.`);for(let{indexPath:r,value:i}of h(e)){if(typeof i!=`object`||!i)throw TypeError(`Expected an object but received ${String(i)}.`);let e=i;t.set(e,s(e,r)),n.push(e)}return y(n,t)}function x(a,o){let s=o?.customGlobals??{},c=[e.configs.recommended,...i.configs.strictTypeChecked,...i.configs.stylisticTypeChecked,{languageOptions:{globals:{...r.builtin,...r.nodeBuiltin,...s},parser:i.parser,parserOptions:o?.parserOptions??{projectService:!0,project:[`./tsconfig.json`]}},plugins:{"@typescript-eslint":i.plugin},rules:{"@typescript-eslint/array-type":[`warn`,{default:`generic`}],"@typescript-eslint/no-non-null-assertion":`off`,"@typescript-eslint/no-unused-vars":[`error`,{argsIgnorePattern:`^_`,caughtErrorsIgnorePattern:`^_`,destructuredArrayIgnorePattern:`^_`,ignoreRestSiblings:!0,varsIgnorePattern:`^_`}],"@typescript-eslint/prefer-nullish-coalescing":`off`}},n.configs.recommended,{rules:{"unicorn/filename-case":`warn`,"unicorn/no-array-callback-reference":`off`,"unicorn/prevent-abbreviations":`off`}},{plugins:{perfectionist:t},rules:{...t.configs[`recommended-natural`].rules,"sort-classes":`off`,"perfectionist/sort-imports":[`error`,{type:`natural`,internalPattern:[`^~/.*`,`^@/.*`,`^#.*`]}],"perfectionist/sort-interfaces":`off`,"perfectionist/sort-jsx-props":`off`,"perfectionist/sort-maps":`off`,"perfectionist/sort-modules":`off`,"perfectionist/sort-objects":`off`,"perfectionist/sort-object-types":`off`,"perfectionist/sort-sets":`off`,"perfectionist/sort-switch-case":`off`,"perfectionist/sort-union-types":`off`}}];return b(...c,...a??[])}export{x as getConfig};
|
package/eslint.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsynaptic/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A common ESLint config factory for TypeScript projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "./src/
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
8
14
|
"scripts": {
|
|
15
|
+
"build": "tsdown",
|
|
16
|
+
"build-tsc": "tsc --build",
|
|
17
|
+
"prepublishOnly": "pnpm build",
|
|
9
18
|
"lint": "eslint",
|
|
10
19
|
"check-types": "tsc --noEmit --extendedDiagnostics"
|
|
11
20
|
},
|
|
12
21
|
"dependencies": {
|
|
13
|
-
"@eslint/js": "^9.
|
|
14
|
-
"eslint": "^9.
|
|
22
|
+
"@eslint/js": "^9.35.0",
|
|
23
|
+
"eslint": "^9.35.0",
|
|
15
24
|
"eslint-plugin-import": "^2.32.0",
|
|
16
25
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
17
26
|
"eslint-plugin-perfectionist": "^4.15.0",
|
|
18
|
-
"eslint-plugin-unicorn": "^
|
|
27
|
+
"eslint-plugin-unicorn": "^61.0.2",
|
|
19
28
|
"globals": "^16.3.0",
|
|
20
29
|
"prettier": "^3.6.2",
|
|
21
|
-
"typescript-eslint": "^8.
|
|
30
|
+
"typescript-eslint": "^8.42.0"
|
|
22
31
|
},
|
|
23
32
|
"devDependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
33
|
+
"@eslint/config-helpers": "^0.3.1",
|
|
34
|
+
"jiti": "^2.5.1",
|
|
35
|
+
"tsdown": "^0.14.2",
|
|
36
|
+
"typescript": "^5.9.2"
|
|
26
37
|
},
|
|
27
|
-
"packageManager": "pnpm@10.
|
|
38
|
+
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b"
|
|
28
39
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config, ConfigWithExtends, ConfigWithExtendsArray } from "@eslint/config-helpers";
|
|
2
2
|
|
|
3
|
+
import { defineConfig } from "@eslint/config-helpers";
|
|
3
4
|
import eslint from "@eslint/js";
|
|
4
5
|
import perfectionist from "eslint-plugin-perfectionist";
|
|
5
6
|
import unicornPlugin from "eslint-plugin-unicorn";
|
|
@@ -7,10 +8,10 @@ import globals from "globals";
|
|
|
7
8
|
import tseslint from "typescript-eslint";
|
|
8
9
|
|
|
9
10
|
export function getConfig(
|
|
10
|
-
customConfig?:
|
|
11
|
+
customConfig?: ConfigWithExtendsArray,
|
|
11
12
|
options?: {
|
|
12
13
|
customGlobals?: Record<string, "readonly" | "writeable">;
|
|
13
|
-
parserOptions?: NonNullable<
|
|
14
|
+
parserOptions?: NonNullable<Config["languageOptions"]>["parserOptions"];
|
|
14
15
|
},
|
|
15
16
|
) {
|
|
16
17
|
const customGlobals = options?.customGlobals ?? {};
|
|
@@ -84,7 +85,7 @@ export function getConfig(
|
|
|
84
85
|
"perfectionist/sort-union-types": "off",
|
|
85
86
|
},
|
|
86
87
|
},
|
|
87
|
-
]
|
|
88
|
+
] as Array<ConfigWithExtends>;
|
|
88
89
|
|
|
89
|
-
return
|
|
90
|
+
return defineConfig(...baseConfig, ...(customConfig ?? []));
|
|
90
91
|
}
|