@labeg/code-style 3.1.1 → 4.0.2

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/.eslintrc.js CHANGED
@@ -6,7 +6,18 @@
6
6
  */
7
7
 
8
8
  const jsAndTsRules = {
9
+ // Eslint rules
9
10
  "sort-imports": "off", // Need found sorter
11
+ "sort-keys": "off", // More nice
12
+ "one-var": ["error", "never"], // More nice
13
+ "no-ternary": "off", // More nice
14
+ "no-void": "off", // Strange rule
15
+ "no-bitwise": "off", // Used in many projects
16
+ "no-inline-comments": "off", // Maybe later?
17
+ "line-comment-position": "off", // Maybe later?
18
+
19
+
20
+ // Eslint moved to Stylistic, but now to buggy for js. Remove after fix bugs in new versions Stylistic
10
21
  "max-len": [
11
22
  "error", {
12
23
  code: 140,
@@ -22,27 +33,40 @@ const jsAndTsRules = {
22
33
  ], // More nice
23
34
  "function-call-argument-newline": ["error", "consistent"], // More nice
24
35
  "quote-props": ["error", "as-needed"], // More nice
25
- "sort-keys": "off", // More nice
26
- "class-methods-use-this": "off", // False positives
27
- "one-var": ["error", "never"], // More nice
28
- "no-ternary": "off", // More nice
29
36
  "multiline-ternary": ["error", "always-multiline"], // More nice
30
37
  "array-element-newline": ["error", "consistent"], // More nice
31
38
  "operator-linebreak": ["error", "after"], // More nice
32
- "no-void": "off", // Strange rule
33
- "max-params": ["error", {max: 4}], // Maybe later?
34
- "no-bitwise": "off", // Used in many projects
35
- "prefer-named-capture-group": "off", // Maybe later?
36
- "dot-location": ["error", "property"], // More nice
37
- "no-inline-comments": "off", // Maybe later?
38
- "line-comment-position": "off", // Maybe later?
39
39
 
40
- "no-duplicate-imports": "off" // Bug, remove later
40
+
41
+ // Stylistic rules
42
+ "@stylistic/max-len": [
43
+ "error", {
44
+ code: 140,
45
+ comments: 140
46
+ }
47
+ ], // More nice, for modern screens
48
+ "@stylistic/padded-blocks": [
49
+ "error", {
50
+ classes: "always",
51
+ blocks: "never",
52
+ switches: "never"
53
+ }
54
+ ], // More nice
55
+ "@stylistic/function-call-argument-newline": ["error", "consistent"], // More nice
56
+ "@stylistic/quote-props": ["error", "as-needed"], // More nice
57
+ "@stylistic/multiline-ternary": ["error", "always-multiline"], // More nice
58
+ "@stylistic/array-element-newline": ["error", "consistent"], // More nice
59
+ "@stylistic/operator-linebreak": ["error", "after"], // More nice
60
+ "@stylistic/no-extra-parens": "off"
41
61
  };
42
62
 
43
63
  module.exports = {
44
64
  extends: [
45
- "eslint:all" // There is no React because they are used strictly with Typescript.
65
+ "eslint:all", // There is no React because they are used strictly with Typescript.
66
+ // "plugin:@stylistic/all-extends" // Bug, begin incorrect formatting, check in new versions
67
+ ],
68
+ plugins: [
69
+ "@stylistic/migrate"
46
70
  ],
47
71
  root: true,
48
72
  env: {
@@ -51,11 +75,6 @@ module.exports = {
51
75
  node: true
52
76
  },
53
77
  ignorePatterns: ["node_modules/*"],
54
- settings: {
55
- react: {
56
- version: "detect"
57
- }
58
- },
59
78
  rules: {
60
79
  ...jsAndTsRules
61
80
  },
@@ -63,19 +82,21 @@ module.exports = {
63
82
  {
64
83
  files: ["**/*.{ts,tsx}"],
65
84
  settings: {
85
+ react: {
86
+ version: "detect"
87
+ },
66
88
  "import/parsers": {
67
89
  "@typescript-eslint/parser": [".ts", ".tsx"]
68
90
  },
69
91
  "import/resolver": {
70
92
  typescript: {
71
- project: "./tsconfig.json"
93
+ project: "tsconfig.json"
72
94
  }
73
95
  }
74
96
  },
75
97
  parser: "@typescript-eslint/parser",
76
98
  parserOptions: {
77
99
  project: "tsconfig.json",
78
- tsconfigRootDir: __dirname,
79
100
  sourceType: "module",
80
101
  ecmaVersion: "latest",
81
102
  ecmaFeatures: {
@@ -84,6 +105,7 @@ module.exports = {
84
105
  },
85
106
  extends: [
86
107
  "eslint:all",
108
+ "plugin:@stylistic/all-extends",
87
109
  "plugin:@typescript-eslint/all",
88
110
  "plugin:react/all",
89
111
  "plugin:react-hooks/recommended",
@@ -102,9 +124,6 @@ module.exports = {
102
124
  "@typescript-eslint/no-confusing-void-expression": "off", // More nice
103
125
  "@typescript-eslint/member-ordering": "off", // Need correct priority
104
126
 
105
- "@typescript-eslint/keyword-spacing": "off", // Bug, remove later
106
- "@typescript-eslint/no-import-type-side-effects": "off", // Bug, remove later
107
-
108
127
  "react/jsx-filename-extension": ["error", {extensions: [".tsx"]}], // Added typescript file extension
109
128
  "react/jsx-no-literals": "off", // Broken rule, not work with ??
110
129
  "react/jsx-max-depth": ["error", {max: 10}], // To small by default
@@ -112,7 +131,6 @@ module.exports = {
112
131
  "react/forbid-component-props": "off", // Conflict with styled-components
113
132
  "react/jsx-uses-react": "off", // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
114
133
  "react/react-in-jsx-scope": "off", // https://ru.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
115
- "react/sort-comp": "off" // Need write priority
116
134
  }
117
135
  }
118
136
  ]
package/.prettierrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "printWidth": 80,
3
+ "tabWidth": 4,
4
+ "useTabs": false,
5
+ "semi": true,
6
+ "singleQuote": false,
7
+ "trailingComma": "none",
8
+ "bracketSpacing": true,
9
+ "jsxBracketSameLine": true,
10
+ "arrowParens": "always",
11
+ "proseWrap": "always"
12
+ }
package/README.md CHANGED
@@ -15,9 +15,19 @@ npm i -D @labeg/code-style
15
15
  Далее в вашь файл eslint config необходимо добавить следующую строчку:
16
16
  ```Javascript
17
17
  module.exports = {
18
- extends: ["@labeg/code-style"],
18
+ extends: ["./node_modules/@labeg/code-style/.eslintrc.js"],
19
19
  rules:{
20
- // override here
20
+ // Override here
21
+ }
22
+ };
23
+ ```
24
+
25
+ Версия для NextJS:
26
+ ```Javascript
27
+ module.exports = {
28
+ extends: ["next/core-web-vitals", "./node_modules/@labeg/code-style/.eslintrc.js"],
29
+ rules: {
30
+ // Override here
21
31
  }
22
32
  };
23
33
  ```
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@labeg/code-style",
3
- "version": "3.1.1",
4
- "main": ".eslintrc.js",
3
+ "version": "4.0.2",
5
4
  "scripts": {
6
5
  "prepublishOnly": "npm version patch"
7
6
  },
@@ -21,6 +20,8 @@
21
20
  "eslint": "^8.55.0",
22
21
  "eslint-plugin-jsx-a11y": "^6.8.0",
23
22
  "eslint-plugin-react": "^7.33.2",
24
- "eslint-plugin-react-hooks": "^4.6.0"
23
+ "eslint-plugin-react-hooks": "^4.6.0",
24
+ "@stylistic/eslint-plugin": "^1.4.1",
25
+ "@stylistic/eslint-plugin-migrate": "^1.4.1"
25
26
  }
26
27
  }