@xsynaptic/eslint-config 0.0.2 → 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.2",
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,137 +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
- import tseslint, { ConfigArray } from "typescript-eslint";
8
+ import tseslint from "typescript-eslint";
7
9
 
8
10
  export function getConfig(
9
- customConfig?: ConfigArray,
10
- options?: {
11
- customGlobals?: Record<string, "readonly" | "writeable">;
12
- withAstro?: boolean;
13
- }
11
+ customConfig?: ConfigArray,
12
+ options?: {
13
+ customGlobals?: Record<string, "readonly" | "writeable">;
14
+ withAstro?: boolean;
15
+ },
14
16
  ) {
15
- const customGlobals = options?.customGlobals ?? {};
16
- const withAstro = options?.withAstro ?? false;
17
-
18
- const baseConfig = [
19
- eslint.configs.recommended,
20
- ...tseslint.configs.strictTypeChecked,
21
- ...tseslint.configs.stylisticTypeChecked,
22
- {
23
- languageOptions: {
24
- parser: tseslint.parser,
25
- parserOptions: {
26
- // projectService: true, // Astro ecosystem tools can't use this yet; 2024Q4
27
- project: ["./tsconfig.json"],
28
- },
29
- globals: {
30
- ...globals.builtin,
31
- ...globals.nodeBuiltin,
32
- ...customGlobals,
33
- },
34
- },
35
- plugins: {
36
- "@typescript-eslint": tseslint.plugin,
37
- },
38
- rules: {
39
- "@typescript-eslint/array-type": ["warn", { default: "generic" }],
40
- "@typescript-eslint/no-unused-vars": [
41
- "error",
42
- {
43
- argsIgnorePattern: "^_",
44
- destructuredArrayIgnorePattern: "^_",
45
- varsIgnorePattern: "^_",
46
- caughtErrorsIgnorePattern: "^_",
47
- ignoreRestSiblings: true,
48
- },
49
- ],
50
- "@typescript-eslint/no-non-null-assertion": "off",
51
- },
52
- },
53
-
54
- /**
55
- * Simple import sort
56
- */
57
- {
58
- plugins: {
59
- "simple-import-sort": simpleImportSortPlugin,
60
- },
61
- rules: {
62
- "simple-import-sort/imports": [
63
- "warn",
64
- {
65
- groups: [
66
- [String.raw`^@?\w`], // External packages
67
- [String.raw`^.*\u0000$`], // Type imports
68
- ["^(@/)(/.*|$)"], // Internal imports prefixed with `@/`
69
- [String.raw`^\u0000`], // Side effect imports
70
- [String.raw`^\.\.(?!/?$)`, String.raw`^\.\./?$`], // Parent imports; put `..` last
71
- [
72
- String.raw`^\./(?=.*/)(?!/?$)`,
73
- String.raw`^\.(?!/?$)`,
74
- String.raw`^\./?$`,
75
- ], // Other relative imports; put same folder imports and `.` last
76
- [String.raw`^.+\.s?css$`], // Style imports
77
- ],
78
- },
79
- ],
80
- "simple-import-sort/exports": "warn",
81
- },
82
- },
17
+ const customGlobals = options?.customGlobals ?? {};
18
+ const withAstro = options?.withAstro ?? false;
83
19
 
84
- /**
85
- * Unicorn
86
- */
87
- unicornPlugin.configs["flat/recommended"],
88
- {
89
- rules: {
90
- "unicorn/filename-case": "warn",
91
- "unicorn/no-array-callback-reference": "off", // I prefer this pattern for filtering/sorting content
92
- "unicorn/prevent-abbreviations": "off", // I *like* abbreviations!
93
- },
94
- },
95
- ] 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;
96
89
 
97
- /**
98
- * Astro support; with some help from...
99
- * @reference - https://github.com/Princesseuh/erika.florist/blob/main/eslint.config.js
100
- */
101
- const astroConfig = [
102
- ...astroPlugin.configs.recommended,
103
- ...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"],
104
97
 
105
- // Remove some safety rules around `any` for various reasons
106
- // Astro.props isn't typed correctly in some contexts, so a bunch of things ends up being `any`
107
- {
108
- files: ["**/*.astro"],
109
- rules: {
110
- "@typescript-eslint/no-unsafe-member-access": "off",
111
- "@typescript-eslint/no-unsafe-call": "off",
112
- "@typescript-eslint/no-unsafe-return": "off",
113
- "@typescript-eslint/no-unsafe-assignment": "off",
114
- "@typescript-eslint/no-unsafe-argument": "off",
115
- },
116
- },
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
+ },
117
110
 
118
- // Disable typed rules for scripts inside Astro files
119
- // https://github.com/ota-meshi/eslint-plugin-astro/issues/240
120
- {
121
- files: ["**/*.astro/*.ts"],
122
- languageOptions: {
123
- parserOptions: {
124
- // eslint-disable-next-line unicorn/no-null
125
- project: null,
126
- },
127
- },
128
- ...tseslint.configs.disableTypeChecked,
129
- },
130
- ] 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;
131
124
 
132
- return tseslint.config([
133
- ...baseConfig,
134
- ...(withAstro ? astroConfig : []),
135
- ...(customConfig ?? []),
136
- ]);
125
+ return tseslint.config([
126
+ ...baseConfig,
127
+ ...(withAstro ? astroConfig : []),
128
+ ...(customConfig ?? []),
129
+ ]);
137
130
  }
package/tsconfig.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "baseUrl": ".",
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true
10
- },
11
- "include": [
12
- "**/*.ts"
13
- ]
14
- }
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"]
18
+ }