@labeg/code-style 5.3.3 → 5.4.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.
Files changed (2) hide show
  1. package/eslint.config.js +86 -71
  2. package/package.json +2 -1
package/eslint.config.js CHANGED
@@ -3,22 +3,50 @@ import js from "@eslint/js";
3
3
  import tseslint from "typescript-eslint";
4
4
  import stylistic from "@stylistic/eslint-plugin";
5
5
  import reactPlugin from "eslint-plugin-react";
6
+ import reactHooks from 'eslint-plugin-react-hooks';
6
7
  import jsxA11y from "eslint-plugin-jsx-a11y";
7
8
  import globals from "globals";
8
9
 
10
+ /**
11
+ * Help by links:
12
+ * https://github.com/eslint/eslint/discussions/18304
13
+ */
14
+
9
15
  /** @type {import("eslint").Linter.Config} */
10
- export default tseslint.config(
16
+ export default [
17
+ // DO NOT PUT OTHER PROPS IN THIS OBJECT
11
18
  {ignores: ["**/node_modules/**", "dist/"]},
12
- {
13
- files: ["**/*.{js}"],
14
- extends: [js.configs.all]
19
+
20
+ // THE IGNORES IS APPLIED ALSO TO THESE FOLLOWING CONFIGS
21
+ {files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"]},
22
+
23
+ js.configs.all,
24
+ ...tseslint.configs.strict,
25
+ ...tseslint.configs.stylistic,
26
+ stylistic.configs["all-flat"],
27
+ reactPlugin.configs.flat.all,
28
+ jsxA11y.flatConfigs.strict,
29
+
30
+ { // don't support flat config yet
31
+ plugins: {
32
+ "react-hooks": reactHooks,
33
+ },
34
+ rules: reactHooks.configs.recommended.rules,
15
35
  },
16
- {
17
- files: ["**/*.{ts}"], // ,tsx
36
+
37
+ ...tseslint.config({
38
+ files: ["**/*.ts"],
18
39
  extends: [
19
- js.configs.all,
20
- tseslint.configs.all
40
+ ...tseslint.configs.strictTypeCheckedOnly,
41
+ ...tseslint.configs.stylisticTypeCheckedOnly
21
42
  ],
43
+ languageOptions: {
44
+ parser: tseslint.parser,
45
+ parserOptions: {
46
+ projectService: true,
47
+ tsconfigRootDir: import.meta.dirname
48
+ }
49
+ },
22
50
  rules: {
23
51
  "@typescript-eslint/no-inferrable-types": "off", // Need for reflection
24
52
  "@typescript-eslint/no-magic-numbers": "off",
@@ -31,77 +59,27 @@ export default tseslint.config(
31
59
  "@typescript-eslint/no-confusing-void-expression": "off", // More nice
32
60
  "@typescript-eslint/member-ordering": "off" // Need correct priority
33
61
  }
34
- },
35
- {
36
- extends: [stylistic.configs["all-flat"]],
37
- rules: {
38
- // Stylistic rules
39
- "@stylistic/max-len": [
40
- "error", {
41
- code: 140,
42
- comments: 140
43
- }
44
- ], // More nice, for modern screens
45
- "@stylistic/padded-blocks": [
46
- "error", {
47
- classes: "always",
48
- blocks: "never",
49
- switches: "never"
50
- }
51
- ], // More nice
52
- "@stylistic/function-call-argument-newline": ["error", "consistent"], // More nice
53
- "@stylistic/quote-props": ["error", "as-needed"], // More nice
54
- "@stylistic/multiline-ternary": ["error", "always-multiline"], // More nice
55
- "@stylistic/array-element-newline": ["error", "consistent"], // More nice
56
- "@stylistic/operator-linebreak": ["error", "after"], // More nice
57
- "@stylistic/no-extra-parens": "off",
58
- "@stylistic/dot-location": ["error", "property"] // Maybe later?
59
- }
60
- },
61
- {
62
- files: ["**/*.{jsx,tsx}"],
63
- extends: [reactPlugin.configs.flat.all],
64
- settings: {
65
- react: {
66
- version: "detect"
67
- }
68
- },
69
- rules: {
70
- "react/jsx-filename-extension": ["error", {extensions: [".jsx", ".tsx"]}], // Added typescript file extension
71
- "react/jsx-no-literals": "off", // Broken rule, not work with ??
72
- "react/jsx-max-depth": ["error", {max: 10}], // To small by default
73
- "react/function-component-definition": ["error", {namedComponents: "arrow-function"}], // Same as eslint func-styles
74
- "react/forbid-component-props": "off", // Conflict with styled-components
75
- "react/require-default-props": "off", // Don't used in modern react
76
- "react/jsx-uses-react": "off", // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
77
- "react/react-in-jsx-scope": "off" // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
78
- }
79
- },
80
- {
81
- extends: [jsxA11y.flatConfigs.strict],
82
- rules: {
62
+ }),
83
63
 
84
- }
85
- },
86
64
  {
87
65
  languageOptions: {
88
- ecmaVersion: 2024,
66
+ ecmaVersion: "latest",
89
67
  sourceType: "module",
90
68
  globals: {
91
69
  ...globals.browser,
92
70
  ...globals.node
93
- },
94
- parserOptions: {
95
- projectService: true,
96
- tsconfigRootDir: import.meta.dirname,
97
- ecmaVersion: "latest",
98
- ecmaFeatures: {
99
- jsx: true
100
- }
71
+ }
72
+ },
73
+ settings: {
74
+ react: {
75
+ version: "detect"
101
76
  }
102
77
  },
103
78
  rules: {
104
- // Eslint rules
79
+
80
+ /**
81
+ * Eslint rules
82
+ */
105
83
  "sort-imports": "off", // Need found sorter
106
84
  "sort-keys": "off", // More nice
107
85
  "one-var": ["error", "never"], // More nice
@@ -130,7 +108,44 @@ export default tseslint.config(
130
108
  "quote-props": ["error", "as-needed"], // More nice
131
109
  "multiline-ternary": ["error", "always-multiline"], // More nice
132
110
  "array-element-newline": ["error", "consistent"], // More nice
133
- "operator-linebreak": ["error", "after"] // More nice
111
+ "operator-linebreak": ["error", "after"], // More nice
112
+
113
+
114
+ /**
115
+ * Stylistic rules
116
+ */
117
+ "@stylistic/max-len": [
118
+ "error", {
119
+ code: 140,
120
+ comments: 140
121
+ }
122
+ ], // More nice, for modern screens
123
+ "@stylistic/padded-blocks": [
124
+ "error", {
125
+ classes: "always",
126
+ blocks: "never",
127
+ switches: "never"
128
+ }
129
+ ], // More nice
130
+ "@stylistic/function-call-argument-newline": ["error", "consistent"], // More nice
131
+ "@stylistic/quote-props": ["error", "as-needed"], // More nice
132
+ "@stylistic/multiline-ternary": ["error", "always-multiline"], // More nice
133
+ "@stylistic/array-element-newline": ["error", "consistent"], // More nice
134
+ "@stylistic/operator-linebreak": ["error", "after"], // More nice
135
+ "@stylistic/no-extra-parens": "off",
136
+ "@stylistic/dot-location": ["error", "property"], // Maybe later?
137
+
138
+ /**
139
+ * React rules
140
+ */
141
+ "react/jsx-filename-extension": ["error", {extensions: [".jsx", ".tsx"]}], // Added typescript file extension
142
+ "react/jsx-no-literals": "off", // Broken rule, not work with ??
143
+ "react/jsx-max-depth": ["error", {max: 10}], // To small by default
144
+ "react/function-component-definition": ["error", {namedComponents: "arrow-function"}], // Same as eslint func-styles
145
+ "react/forbid-component-props": "off", // Conflict with styled-components
146
+ "react/require-default-props": "off", // Don't used in modern react
147
+ "react/jsx-uses-react": "off", // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
148
+ "react/react-in-jsx-scope": "off" // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
134
149
  }
135
150
  }
136
- );
151
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labeg/code-style",
3
- "version": "5.3.3",
3
+ "version": "5.4.0",
4
4
  "author": "Eugene Labutin",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/LabEG/code-style#readme",
@@ -37,6 +37,7 @@
37
37
  "eslint": "^9.17.0",
38
38
  "eslint-plugin-jsx-a11y": "^6.10.2",
39
39
  "eslint-plugin-react": "^7.37.3",
40
+ "eslint-plugin-react-hooks": "^5.1.0",
40
41
  "typescript-eslint": "^8.18.2"
41
42
  },
42
43
  "devDependencies": {