@singlepixellab/eslint-config 2.0.1 → 2.2.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 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.0.1",
3
+ "version": "2.2.0",
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 .",
@@ -79,6 +83,7 @@
79
83
  "eslint-plugin-prettier": "^5.5.5",
80
84
  "eslint-plugin-react": "^7.37.5",
81
85
  "eslint-plugin-react-hooks": "^7.0.1",
82
- "globals": "^17.4.0"
86
+ "globals": "^17.4.0",
87
+ "typescript-eslint": "^8.58.2"
83
88
  }
84
89
  }
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
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",
@@ -169,7 +169,7 @@ export default [
169
169
  "error",
170
170
  {
171
171
  "elements": ["img", "object", "area", 'input[type="image"]'],
172
- "img": [],
172
+ "img": ["Image"],
173
173
  "object": [],
174
174
  "area": [],
175
175
  'input[type="image"]': [],
@@ -273,7 +273,7 @@ export default [
273
273
  labelComponents: [],
274
274
  labelAttributes: [],
275
275
  controlComponents: [],
276
- assert: "both",
276
+ assert: "either",
277
277
  depth: 25,
278
278
  },
279
279
  ],
@@ -382,6 +382,8 @@ export default [
382
382
  "error",
383
383
  {
384
384
  nav: ["navigation"],
385
+ ul: ["list"],
386
+ ol: ["list"],
385
387
  },
386
388
  ],
387
389
 
package/rules/styles.js CHANGED
@@ -175,9 +175,6 @@ export default [
175
175
  // Enforce PascalCase for user-defined JSX components
176
176
  "@stylistic/jsx-pascal-case": "warn",
177
177
 
178
- // Disallow multiple spaces between inline JSX props
179
- "@stylistic/jsx-props-no-multi-spaces": "warn",
180
-
181
178
  // Enforce the consistent use of either double or single quotes in JSX
182
179
  // attributes
183
180
  "@stylistic/jsx-quotes": ["warn", "prefer-double"],
@@ -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
+ ];