@singlepixellab/eslint-config 2.1.0 → 2.2.1

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 CHANGED
@@ -6,6 +6,7 @@ The ESLint rules and configs used by Single Pixel Lab.
6
6
 
7
7
  - Node.js ≥ 18
8
8
  - ESLint ≥ 9
9
+ - TypeScript ≥ 3.3.1
9
10
 
10
11
  ## Usage
11
12
 
@@ -40,15 +41,16 @@ export default [...styles, ...react];
40
41
 
41
42
  Available modules:
42
43
 
43
- | Module | Import | Description |
44
- | -------- | ---------------------------------------- | ------------------------------ |
45
- | Core | `@singlepixellab/eslint-config/core` | Base ESLint rules |
46
- | Ignore | `@singlepixellab/eslint-config/ignores` | Default ignore patterns |
47
- | Import | `@singlepixellab/eslint-config/imports` | Import ordering and validation |
48
- | JSDoc | `@singlepixellab/eslint-config/jsdoc` | JSDoc linting |
49
- | Prettier | `@singlepixellab/eslint-config/prettier` | Prettier integration |
50
- | React | `@singlepixellab/eslint-config/react` | React and Hooks rules |
51
- | Style | `@singlepixellab/eslint-config/styles` | Stylistic rules |
44
+ | Module | Import | Description |
45
+ | ---------- | ------------------------------------------ | ------------------------------ |
46
+ | Core | `@singlepixellab/eslint-config/core` | Base ESLint rules |
47
+ | Ignore | `@singlepixellab/eslint-config/ignores` | Default ignore patterns |
48
+ | Import | `@singlepixellab/eslint-config/imports` | Import ordering and validation |
49
+ | JSDoc | `@singlepixellab/eslint-config/jsdoc` | JSDoc linting |
50
+ | Prettier | `@singlepixellab/eslint-config/prettier` | Prettier integration |
51
+ | React | `@singlepixellab/eslint-config/react` | React and Hooks rules |
52
+ | Style | `@singlepixellab/eslint-config/styles` | Stylistic rules |
53
+ | TypeScript | `@singlepixellab/eslint-config/typescript` | TypeScript linting |
52
54
 
53
55
  ### Named exports
54
56
 
package/eslint.config.js CHANGED
@@ -5,12 +5,15 @@ import react from "./rules/react.js";
5
5
  import prettier from "./rules/prettier.js";
6
6
  import jsdoc from "./rules/jsdoc.js";
7
7
  import styles from "./rules/styles.js";
8
+ import typescript from "./rules/typescript.js";
8
9
 
9
10
  /** @type {import('eslint').Linter.Config[]} */
10
11
  export default [
11
12
  // Global ignores should always be first
12
13
  ...ignores,
13
14
 
15
+ ...core,
16
+
14
17
  // eslint-plugin-import
15
18
  ...imports,
16
19
 
@@ -20,7 +23,8 @@ export default [
20
23
  // eslint-plugin-react, eslint-plugin-react-hooks etc
21
24
  ...react,
22
25
 
23
- ...core,
26
+ // @typescript-eslint
27
+ ...typescript,
24
28
 
25
29
  // styles: @stylistic/eslint-plugin
26
30
  ...styles,
package/index.js CHANGED
@@ -9,3 +9,4 @@ export { default as jsdocConfig } from "./rules/jsdoc.js";
9
9
  export { default as prettierConfig } from "./rules/prettier.js";
10
10
  export { default as reactConfig } from "./rules/react.js";
11
11
  export { default as stylesConfig } from "./rules/styles.js";
12
+ export { default as typescriptConfig } from "./rules/typescript.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singlepixellab/eslint-config",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "The ESLint rules and configs used by Single Pixel Lab",
5
5
  "author": "Single Pixel Lab",
6
6
  "keywords": [
@@ -50,13 +50,17 @@
50
50
  },
51
51
  "./styles": {
52
52
  "import": "./rules/styles.js"
53
+ },
54
+ "./typescript": {
55
+ "import": "./rules/typescript.js"
53
56
  }
54
57
  },
55
58
  "engines": {
56
59
  "node": ">=18"
57
60
  },
58
61
  "peerDependencies": {
59
- "eslint": ">= 9"
62
+ "eslint": ">= 9",
63
+ "typescript": ">=3.3.1"
60
64
  },
61
65
  "scripts": {
62
66
  "format": "prettier --cache --write .",
@@ -73,12 +77,14 @@
73
77
  "@eslint/js": "^9.39.4",
74
78
  "@stylistic/eslint-plugin": "^5.10.0",
75
79
  "eslint-config-prettier": "^10.1.8",
80
+ "eslint-import-resolver-typescript": "^4.4.4",
76
81
  "eslint-plugin-import": "^2.32.0",
77
82
  "eslint-plugin-jsdoc": "^62.7.1",
78
83
  "eslint-plugin-jsx-a11y": "^6.10.2",
79
84
  "eslint-plugin-prettier": "^5.5.5",
80
85
  "eslint-plugin-react": "^7.37.5",
81
86
  "eslint-plugin-react-hooks": "^7.0.1",
82
- "globals": "^17.4.0"
87
+ "globals": "^17.4.0",
88
+ "typescript-eslint": "^8.58.2"
83
89
  }
84
90
  }
package/rules/core.js CHANGED
@@ -8,8 +8,8 @@ export default [
8
8
  ...js.configs.recommended,
9
9
  },
10
10
  {
11
- name: "spl/base",
12
- files: ["**/*.{js,mjs,cjs}"],
11
+ name: "spl/core",
12
+ files: ["**/*.{js,mjs,cjs,ts,tsx,mts,cts}"],
13
13
  languageOptions: {
14
14
  ecmaVersion: "latest",
15
15
  sourceType: "module",
package/rules/ignores.js CHANGED
@@ -12,6 +12,7 @@ export default [
12
12
  "**/public/build/**",
13
13
  "**/dist/**",
14
14
  "**/coverage/**",
15
+ "next-env.d.ts",
15
16
 
16
17
  // Prismic auto-generated files
17
18
  "customtypes",
package/rules/imports.js CHANGED
@@ -5,7 +5,20 @@ export default [
5
5
  importPlugin.flatConfigs.recommended,
6
6
  {
7
7
  name: "spl/imports",
8
- files: ["**/*.{js,mjs,cjs}"],
8
+ files: ["**/*.{js,mjs,cjs,ts,tsx,mts,cts}"],
9
+ settings: {
10
+ "import/parsers": {
11
+ "@typescript-eslint/parser": [".ts", ".mts", ".cts", ".tsx", ".d.ts"],
12
+ },
13
+ "import/resolver": {
14
+ node: {
15
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
16
+ },
17
+ typescript: {
18
+ alwaysTryTypes: true,
19
+ },
20
+ },
21
+ },
9
22
  rules: {
10
23
  // Ensures imports point to a file/module that exists, prevents broken
11
24
  // imports
@@ -55,8 +68,34 @@ export default [
55
68
  "import/order": [
56
69
  "error",
57
70
  {
58
- groups: [
59
- ["builtin", "external", "internal", "parent", "sibling", "index"],
71
+ "alphabetize": {
72
+ order: "asc",
73
+ caseInsensitive: true,
74
+ },
75
+ "distinctGroup": false,
76
+ "newlines-between": "always",
77
+ "named": {
78
+ enabled: true,
79
+ types: "types-last",
80
+ },
81
+ "sortTypesGroup": true,
82
+ "pathGroups": [
83
+ {
84
+ pattern: "~*/**",
85
+ group: "external",
86
+ position: "after",
87
+ },
88
+ ],
89
+ "groups": [
90
+ [
91
+ "builtin",
92
+ "external",
93
+ "internal",
94
+ "parent",
95
+ "sibling",
96
+ "index",
97
+ "type",
98
+ ],
60
99
  ],
61
100
  },
62
101
  ],
package/rules/react.js CHANGED
@@ -6,7 +6,7 @@ import reactHooks from "eslint-plugin-react-hooks";
6
6
  export default [
7
7
  {
8
8
  name: "spl/react",
9
- files: ["**/*.js"],
9
+ files: ["**/*.{js,tsx}"],
10
10
  settings: {
11
11
  react: {
12
12
  version: "detect",
@@ -64,9 +64,11 @@ export default [
64
64
  // Enforce or disallow spaces around equal sign
65
65
  "react/jsx-equals-spacing": "off",
66
66
 
67
- // No jsx extension
68
- // https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
69
- "react/jsx-filename-extension": ["error", { extensions: [".js"] }],
67
+ // Restrict file extensions that may contain JSX
68
+ "react/jsx-filename-extension": [
69
+ "error",
70
+ { extensions: [".js", ".tsx"] },
71
+ ],
70
72
 
71
73
  // Enforce shorthand or standard form for React fragments
72
74
  "react/jsx-fragments": ["warn", "syntax"],
@@ -169,7 +171,7 @@ export default [
169
171
  "error",
170
172
  {
171
173
  "elements": ["img", "object", "area", 'input[type="image"]'],
172
- "img": [],
174
+ "img": ["Image"],
173
175
  "object": [],
174
176
  "area": [],
175
177
  'input[type="image"]': [],
@@ -0,0 +1,38 @@
1
+ import tsEslint from "typescript-eslint";
2
+
3
+ /** @type {import('eslint').Linter.Config[]} */
4
+ export default [
5
+ ...tsEslint.configs.recommended,
6
+ ...tsEslint.configs.stylistic,
7
+ {
8
+ name: "spl/typescript",
9
+ files: ["**/*.{ts,tsx,mts,cts}"],
10
+ plugins: {
11
+ "@typescript-eslint": tsEslint.plugin,
12
+ },
13
+ languageOptions: {
14
+ parser: tsEslint.parser,
15
+ parserOptions: {
16
+ ecmaFeatures: {
17
+ jsx: true,
18
+ },
19
+ },
20
+ },
21
+ rules: {
22
+ // Ensure that all explicitly declared properties are actually used
23
+ "no-unused-vars": "off",
24
+ "@typescript-eslint/no-unused-vars": [
25
+ "error",
26
+ {
27
+ args: "all",
28
+ argsIgnorePattern: "^_",
29
+ caughtErrors: "all",
30
+ caughtErrorsIgnorePattern: "^_",
31
+ destructuredArrayIgnorePattern: "^_",
32
+ varsIgnorePattern: "^_",
33
+ ignoreRestSiblings: true,
34
+ },
35
+ ],
36
+ },
37
+ },
38
+ ];