@xsynaptic/eslint-config 0.0.3 → 0.0.4

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.
@@ -1,5 +1,9 @@
1
1
  {
2
- "cSpell.words": [
3
- "xsynaptic"
4
- ]
5
- }
2
+ "cSpell.words": ["xsynaptic"],
3
+ "eslint.validate": ["javascript", "typescript"],
4
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
5
+ "editor.codeActionsOnSave": {
6
+ "source.fixAll": "always",
7
+ "source.fixAll.eslint": "always"
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,29 +1,30 @@
1
1
  {
2
- "name": "@xsynaptic/eslint-config",
3
- "version": "0.0.3",
4
- "description": "A common ESLint config factory for TypeScript and Astro projects",
5
- "type": "module",
6
- "license": "MIT",
7
- "main": "./src/get-config.ts",
8
- "scripts": {
9
- "lint": "eslint",
10
- "check-types": "tsc --noEmit --extendedDiagnostics"
11
- },
12
- "dependencies": {
13
- "@eslint/js": "^9.19.0",
14
- "eslint": "^9.19.0",
15
- "eslint-plugin-astro": "^1.3.1",
16
- "eslint-plugin-import": "^2.31.0",
17
- "eslint-plugin-jsx-a11y": "^6.10.2",
18
- "eslint-plugin-simple-import-sort": "^12.1.1",
19
- "eslint-plugin-unicorn": "^56.0.1",
20
- "globals": "^15.14.0",
21
- "typescript-eslint": "^8.21.0"
22
- },
23
- "devDependencies": {
24
- "@types/eslint__js": "^8.42.3",
25
- "jiti": "^2.4.2",
26
- "typescript": "^5.7.3"
27
- },
28
- "packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
2
+ "name": "@xsynaptic/eslint-config",
3
+ "version": "0.0.4",
4
+ "description": "A common ESLint config factory for TypeScript and Astro projects",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./src/get-config.ts",
8
+ "scripts": {
9
+ "lint": "eslint",
10
+ "check-types": "tsc --noEmit --extendedDiagnostics"
11
+ },
12
+ "dependencies": {
13
+ "@eslint/js": "^9.21.0",
14
+ "eslint": "^9.21.0",
15
+ "eslint-plugin-astro": "^1.3.1",
16
+ "eslint-plugin-import": "^2.31.0",
17
+ "eslint-plugin-jsx-a11y": "^6.10.2",
18
+ "eslint-plugin-perfectionist": "^4.9.0",
19
+ "eslint-plugin-unicorn": "^56.0.1",
20
+ "globals": "^15.15.0",
21
+ "prettier": "^3.5.3",
22
+ "typescript-eslint": "^8.25.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/eslint__js": "^8.42.3",
26
+ "jiti": "^2.4.2",
27
+ "typescript": "^5.8.2"
28
+ },
29
+ "packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
29
30
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @type {import('prettier').Config}
3
+ */
4
+ export default {
5
+ printWidth: 100,
6
+ useTabs: true,
7
+ };
package/src/get-config.ts CHANGED
@@ -1,139 +1,130 @@
1
+ import type { ConfigArray } from "typescript-eslint";
2
+
1
3
  import eslint from "@eslint/js";
2
4
  import astroPlugin from "eslint-plugin-astro";
3
- import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
5
+ import perfectionist from "eslint-plugin-perfectionist";
4
6
  import unicornPlugin from "eslint-plugin-unicorn";
5
7
  import globals from "globals";
6
8
  import tseslint from "typescript-eslint";
7
9
 
8
- import type { ConfigArray } from "typescript-eslint";
9
-
10
10
  export function getConfig(
11
- customConfig?: ConfigArray,
12
- options?: {
13
- customGlobals?: Record<string, "readonly" | "writeable">;
14
- withAstro?: boolean;
15
- }
11
+ customConfig?: ConfigArray,
12
+ options?: {
13
+ customGlobals?: Record<string, "readonly" | "writeable">;
14
+ withAstro?: boolean;
15
+ },
16
16
  ) {
17
- const customGlobals = options?.customGlobals ?? {};
18
- const withAstro = options?.withAstro ?? false;
19
-
20
- const baseConfig = [
21
- eslint.configs.recommended,
22
- ...tseslint.configs.strictTypeChecked,
23
- ...tseslint.configs.stylisticTypeChecked,
24
- {
25
- languageOptions: {
26
- parser: tseslint.parser,
27
- parserOptions: {
28
- // projectService: true, // Astro ecosystem tools can't use this yet; 2024Q4
29
- project: ["./tsconfig.json"],
30
- },
31
- globals: {
32
- ...globals.builtin,
33
- ...globals.nodeBuiltin,
34
- ...customGlobals,
35
- },
36
- },
37
- plugins: {
38
- "@typescript-eslint": tseslint.plugin,
39
- },
40
- rules: {
41
- "@typescript-eslint/array-type": ["warn", { default: "generic" }],
42
- "@typescript-eslint/no-unused-vars": [
43
- "error",
44
- {
45
- argsIgnorePattern: "^_",
46
- destructuredArrayIgnorePattern: "^_",
47
- varsIgnorePattern: "^_",
48
- caughtErrorsIgnorePattern: "^_",
49
- ignoreRestSiblings: true,
50
- },
51
- ],
52
- "@typescript-eslint/no-non-null-assertion": "off",
53
- },
54
- },
55
-
56
- /**
57
- * Simple import sort
58
- */
59
- {
60
- plugins: {
61
- "simple-import-sort": simpleImportSortPlugin,
62
- },
63
- rules: {
64
- "simple-import-sort/imports": [
65
- "warn",
66
- {
67
- groups: [
68
- [String.raw`^@?\w`], // External packages
69
- [String.raw`^.*\u0000$`], // Type imports
70
- ["^(@/)(/.*|$)"], // Internal imports prefixed with `@/`
71
- [String.raw`^\u0000`], // Side effect imports
72
- [String.raw`^\.\.(?!/?$)`, String.raw`^\.\./?$`], // Parent imports; put `..` last
73
- [
74
- String.raw`^\./(?=.*/)(?!/?$)`,
75
- String.raw`^\.(?!/?$)`,
76
- String.raw`^\./?$`,
77
- ], // Other relative imports; put same folder imports and `.` last
78
- [String.raw`^.+\.s?css$`], // Style imports
79
- ],
80
- },
81
- ],
82
- "simple-import-sort/exports": "warn",
83
- },
84
- },
17
+ const customGlobals = options?.customGlobals ?? {};
18
+ const withAstro = options?.withAstro ?? false;
85
19
 
86
- /**
87
- * Unicorn
88
- */
89
- unicornPlugin.configs["flat/recommended"],
90
- {
91
- rules: {
92
- "unicorn/filename-case": "warn",
93
- "unicorn/no-array-callback-reference": "off", // I prefer this pattern for filtering/sorting content
94
- "unicorn/prevent-abbreviations": "off", // I *like* abbreviations!
95
- },
96
- },
97
- ] satisfies ConfigArray;
20
+ const baseConfig = [
21
+ eslint.configs.recommended,
22
+ ...tseslint.configs.strictTypeChecked,
23
+ ...tseslint.configs.stylisticTypeChecked,
24
+ {
25
+ languageOptions: {
26
+ globals: {
27
+ ...globals.builtin,
28
+ ...globals.nodeBuiltin,
29
+ ...customGlobals,
30
+ },
31
+ parser: tseslint.parser,
32
+ parserOptions: {
33
+ // projectService: true, // Astro ecosystem tools can't use this yet; 2024Q4
34
+ project: ["./tsconfig.json"],
35
+ },
36
+ },
37
+ plugins: {
38
+ "@typescript-eslint": tseslint.plugin,
39
+ },
40
+ rules: {
41
+ "@typescript-eslint/array-type": ["warn", { default: "generic" }],
42
+ "@typescript-eslint/no-non-null-assertion": "off",
43
+ "@typescript-eslint/no-unused-vars": [
44
+ "error",
45
+ {
46
+ argsIgnorePattern: "^_",
47
+ caughtErrorsIgnorePattern: "^_",
48
+ destructuredArrayIgnorePattern: "^_",
49
+ ignoreRestSiblings: true,
50
+ varsIgnorePattern: "^_",
51
+ },
52
+ ],
53
+ },
54
+ },
55
+ unicornPlugin.configs["flat/recommended"],
56
+ {
57
+ rules: {
58
+ "unicorn/filename-case": "warn",
59
+ "unicorn/no-array-callback-reference": "off", // I prefer this pattern for filtering/sorting content
60
+ "unicorn/prevent-abbreviations": "off", // I *like* abbreviations!
61
+ },
62
+ },
63
+ {
64
+ plugins: {
65
+ perfectionist,
66
+ },
67
+ rules: {
68
+ ...perfectionist.configs["recommended-natural"].rules,
69
+ "sort-classes": "off",
70
+ "perfectionist/sort-imports": [
71
+ "error",
72
+ {
73
+ type: "natural",
74
+ internalPattern: ["^~/.*", "^@/.*", "^#.*"],
75
+ },
76
+ ],
77
+ "perfectionist/sort-interfaces": "off",
78
+ "perfectionist/sort-jsx-props": "off",
79
+ "perfectionist/sort-maps": "off",
80
+ "perfectionist/sort-modules": "off",
81
+ "perfectionist/sort-objects": "off",
82
+ "perfectionist/sort-object-types": "off",
83
+ "perfectionist/sort-sets": "off",
84
+ "perfectionist/sort-switch-case": "off",
85
+ "perfectionist/sort-union-types": "off",
86
+ },
87
+ },
88
+ ] satisfies ConfigArray;
98
89
 
99
- /**
100
- * Astro support; with some help from...
101
- * @reference - https://github.com/Princesseuh/erika.florist/blob/main/eslint.config.js
102
- */
103
- const astroConfig = [
104
- ...astroPlugin.configs.recommended,
105
- ...astroPlugin.configs["jsx-a11y-strict"],
90
+ /**
91
+ * Astro support; with some help from...
92
+ * @reference - https://github.com/Princesseuh/erika.florist/blob/main/eslint.config.js
93
+ */
94
+ const astroConfig = [
95
+ ...astroPlugin.configs.recommended,
96
+ ...astroPlugin.configs["jsx-a11y-strict"],
106
97
 
107
- // Remove some safety rules around `any` for various reasons
108
- // Astro.props isn't typed correctly in some contexts, so a bunch of things ends up being `any`
109
- {
110
- files: ["**/*.astro"],
111
- rules: {
112
- "@typescript-eslint/no-unsafe-member-access": "off",
113
- "@typescript-eslint/no-unsafe-call": "off",
114
- "@typescript-eslint/no-unsafe-return": "off",
115
- "@typescript-eslint/no-unsafe-assignment": "off",
116
- "@typescript-eslint/no-unsafe-argument": "off",
117
- },
118
- },
98
+ // Remove some safety rules around `any` for various reasons
99
+ // Astro.props isn't typed correctly in some contexts, so a bunch of things ends up being `any`
100
+ {
101
+ files: ["**/*.astro"],
102
+ rules: {
103
+ "@typescript-eslint/no-unsafe-argument": "off",
104
+ "@typescript-eslint/no-unsafe-assignment": "off",
105
+ "@typescript-eslint/no-unsafe-call": "off",
106
+ "@typescript-eslint/no-unsafe-member-access": "off",
107
+ "@typescript-eslint/no-unsafe-return": "off",
108
+ },
109
+ },
119
110
 
120
- // Disable typed rules for scripts inside Astro files
121
- // https://github.com/ota-meshi/eslint-plugin-astro/issues/240
122
- {
123
- files: ["**/*.astro/*.ts"],
124
- languageOptions: {
125
- parserOptions: {
126
- // eslint-disable-next-line unicorn/no-null
127
- project: null,
128
- },
129
- },
130
- ...tseslint.configs.disableTypeChecked,
131
- },
132
- ] satisfies ConfigArray;
111
+ // Disable typed rules for scripts inside Astro files
112
+ // https://github.com/ota-meshi/eslint-plugin-astro/issues/240
113
+ {
114
+ files: ["**/*.astro/*.ts"],
115
+ languageOptions: {
116
+ parserOptions: {
117
+ // eslint-disable-next-line unicorn/no-null
118
+ project: null,
119
+ },
120
+ },
121
+ ...tseslint.configs.disableTypeChecked,
122
+ },
123
+ ] satisfies ConfigArray;
133
124
 
134
- return tseslint.config([
135
- ...baseConfig,
136
- ...(withAstro ? astroConfig : []),
137
- ...(customConfig ?? []),
138
- ]);
125
+ return tseslint.config([
126
+ ...baseConfig,
127
+ ...(withAstro ? astroConfig : []),
128
+ ...(customConfig ?? []),
129
+ ]);
139
130
  }
package/tsconfig.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "moduleResolution": "bundler",
6
- "baseUrl": ".",
7
- "allowJs": true,
8
- "checkJs": true,
9
- "esModuleInterop": true,
10
- "isolatedModules": true,
11
- "noEmit": true,
12
- "skipLibCheck": true,
13
- "strict": true,
14
- "strictNullChecks": true,
15
- "verbatimModuleSyntax": true
16
- },
17
- "include": [
18
- "**/*.ts"
19
- ]
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "bundler",
6
+ "baseUrl": ".",
7
+ "allowJs": true,
8
+ "checkJs": true,
9
+ "esModuleInterop": true,
10
+ "isolatedModules": true,
11
+ "noEmit": true,
12
+ "skipLibCheck": true,
13
+ "strict": true,
14
+ "strictNullChecks": true,
15
+ "verbatimModuleSyntax": true
16
+ },
17
+ "include": ["**/*.ts", "prettier.config.mjs"]
20
18
  }