@labeg/code-style 5.3.2 → 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 +87 -68
  2. package/package.json +2 -1
package/eslint.config.js CHANGED
@@ -3,18 +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
18
+ {ignores: ["**/node_modules/**", "dist/"]},
19
+
20
+ // THE IGNORES IS APPLIED ALSO TO THESE FOLLOWING CONFIGS
21
+ {files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"]},
22
+
11
23
  js.configs.all,
12
- {
13
- files: ["**/*.{ts}"], // ,tsx
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,
35
+ },
36
+
37
+ ...tseslint.config({
38
+ files: ["**/*.ts"],
14
39
  extends: [
15
- js.configs.all,
16
- tseslint.configs.all
40
+ ...tseslint.configs.strictTypeCheckedOnly,
41
+ ...tseslint.configs.stylisticTypeCheckedOnly
17
42
  ],
43
+ languageOptions: {
44
+ parser: tseslint.parser,
45
+ parserOptions: {
46
+ projectService: true,
47
+ tsconfigRootDir: import.meta.dirname
48
+ }
49
+ },
18
50
  rules: {
19
51
  "@typescript-eslint/no-inferrable-types": "off", // Need for reflection
20
52
  "@typescript-eslint/no-magic-numbers": "off",
@@ -27,77 +59,27 @@ export default tseslint.config(
27
59
  "@typescript-eslint/no-confusing-void-expression": "off", // More nice
28
60
  "@typescript-eslint/member-ordering": "off" // Need correct priority
29
61
  }
30
- },
31
- {
32
- extends: [stylistic.configs["all-flat"]],
33
- rules: {
34
- // Stylistic rules
35
- "@stylistic/max-len": [
36
- "error", {
37
- code: 140,
38
- comments: 140
39
- }
40
- ], // More nice, for modern screens
41
- "@stylistic/padded-blocks": [
42
- "error", {
43
- classes: "always",
44
- blocks: "never",
45
- switches: "never"
46
- }
47
- ], // More nice
48
- "@stylistic/function-call-argument-newline": ["error", "consistent"], // More nice
49
- "@stylistic/quote-props": ["error", "as-needed"], // More nice
50
- "@stylistic/multiline-ternary": ["error", "always-multiline"], // More nice
51
- "@stylistic/array-element-newline": ["error", "consistent"], // More nice
52
- "@stylistic/operator-linebreak": ["error", "after"], // More nice
53
- "@stylistic/no-extra-parens": "off",
54
- "@stylistic/dot-location": ["error", "property"] // Maybe later?
55
- }
56
- },
57
- {
58
- files: ["**/*.{jsx,tsx}"],
59
- extends: [reactPlugin.configs.flat.all],
60
- settings: {
61
- react: {
62
- version: "detect"
63
- }
64
- },
65
- rules: {
66
- "react/jsx-filename-extension": ["error", {extensions: [".jsx", ".tsx"]}], // Added typescript file extension
67
- "react/jsx-no-literals": "off", // Broken rule, not work with ??
68
- "react/jsx-max-depth": ["error", {max: 10}], // To small by default
69
- "react/function-component-definition": ["error", {namedComponents: "arrow-function"}], // Same as eslint func-styles
70
- "react/forbid-component-props": "off", // Conflict with styled-components
71
- "react/require-default-props": "off", // Don't used in modern react
72
- "react/jsx-uses-react": "off", // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
73
- "react/react-in-jsx-scope": "off" // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
74
- }
75
- },
76
- {
77
- extends: [jsxA11y.flatConfigs.strict],
78
- rules: {
62
+ }),
79
63
 
80
- }
81
- },
82
64
  {
83
65
  languageOptions: {
84
- ecmaVersion: 2024,
66
+ ecmaVersion: "latest",
85
67
  sourceType: "module",
86
68
  globals: {
87
69
  ...globals.browser,
88
70
  ...globals.node
89
- },
90
- parserOptions: {
91
- projectService: true,
92
- tsconfigRootDir: import.meta.dirname,
93
- ecmaVersion: "latest",
94
- ecmaFeatures: {
95
- jsx: true
96
- }
71
+ }
72
+ },
73
+ settings: {
74
+ react: {
75
+ version: "detect"
97
76
  }
98
77
  },
99
78
  rules: {
100
- // Eslint rules
79
+
80
+ /**
81
+ * Eslint rules
82
+ */
101
83
  "sort-imports": "off", // Need found sorter
102
84
  "sort-keys": "off", // More nice
103
85
  "one-var": ["error", "never"], // More nice
@@ -126,7 +108,44 @@ export default tseslint.config(
126
108
  "quote-props": ["error", "as-needed"], // More nice
127
109
  "multiline-ternary": ["error", "always-multiline"], // More nice
128
110
  "array-element-newline": ["error", "consistent"], // More nice
129
- "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
130
149
  }
131
150
  }
132
- );
151
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labeg/code-style",
3
- "version": "5.3.2",
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": {