@labeg/code-style 6.8.0 → 6.10.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 (3) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +89 -86
  3. package/package.json +22 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [6.10.0] - 2025-11-15
6
+
7
+ ### 🚀 Features
8
+
9
+ - Add issue templates for bug reports and feature requests, enhance contributing guidelines
10
+
11
+ # Changelog
12
+
13
+ All notable changes to this project will be documented in this file.
14
+
15
+ ## [6.9.0] - 2025-11-15
16
+
17
+ ### 🚀 Features
18
+
19
+ - Add CodeQL advanced analysis workflow
20
+
21
+ # Changelog
22
+
23
+ All notable changes to this project will be documented in this file.
24
+
5
25
  ## [6.8.0] - 2025-11-15
6
26
 
7
27
  ### 🚀 Features
package/README.md CHANGED
@@ -1,135 +1,138 @@
1
1
  # CodeStyle
2
2
 
3
+ ![npm version](https://img.shields.io/npm/v/@labeg/code-style.svg)
4
+ ![npm downloads](https://img.shields.io/npm/dm/@labeg/code-style.svg)
3
5
  ![GitHub](https://img.shields.io/github/license/LabEG/code-style.svg)
6
+ ![build status](https://github.com/LabEG/code-style/workflows/Test%20Pull%20Request/badge.svg)
4
7
 
5
- В этом репозитории я собираю файлы стилей для облегчения синхронизации между проектами.
8
+ Comprehensive ESLint configuration for TypeScript and React projects with strict code quality rules.
6
9
 
7
- ## Подключение
10
+ ## Features
8
11
 
9
- Для подключения необходимо установить пакет командой:
12
+ - **ESLint 9+** with flat config format
13
+ - ✅ **TypeScript** support with strict rules
14
+ - ✅ **React 19+** and React Hooks best practices
15
+ - ✅ **Accessibility** checks (jsx-a11y)
16
+ - ✅ **Code style** enforcement (@stylistic)
17
+ - ✅ **Modern JavaScript** standards
10
18
 
11
- ```Bash
12
- npm i -D @labeg/code-style
19
+ ## Installation
20
+
21
+ Install the package as a dev dependency:
22
+
23
+ ```bash
24
+ npm install -D @labeg/code-style
13
25
  ```
14
26
 
15
- Далее в ваш файл eslint config необходимо добавить следующую строку:
27
+ ## Usage
28
+
29
+ ### ESLint 9+ (Flat Config)
16
30
 
17
- ```Javascript
18
- module.exports = {
19
- extends: ["./node_modules/@labeg/code-style/.eslintrc.js"],
20
- rules:{
21
- // Override here
31
+ Create or update your `eslint.config.js`:
32
+
33
+ ```javascript
34
+ import codeStyle from "@labeg/code-style";
35
+
36
+ export default [
37
+ ...codeStyle,
38
+ {
39
+ // Your custom overrides
40
+ rules: {
41
+ // Override specific rules here
42
+ }
22
43
  }
23
- };
44
+ ];
24
45
  ```
25
46
 
26
- Версия для NextJS:
47
+ ### Next.js Projects
27
48
 
28
- ```Javascript
29
- module.exports = {
30
- extends: ["next/core-web-vitals", "./node_modules/@labeg/code-style/.eslintrc.js"],
31
- rules: {
32
- // Override here
49
+ ```javascript
50
+ import codeStyle from "@labeg/code-style";
51
+
52
+ export default [
53
+ ...codeStyle,
54
+ {
55
+ rules: {
56
+ // Next.js specific overrides
57
+ "react/react-in-jsx-scope": "off"
58
+ }
33
59
  }
34
- };
60
+ ];
61
+ ```
62
+
63
+ ### TypeScript Projects
64
+
65
+ The configuration automatically works with TypeScript files (`.ts`, `.tsx`). Make sure you have `typescript` installed:
66
+
67
+ ```bash
68
+ npm install -D typescript
35
69
  ```
36
70
 
37
- ## Рекомендации
38
71
 
39
- ### Не заканчивать строку ничем
72
+ ## Code Style Philosophy
40
73
 
41
- Строка всегда должна заканчиваться знаком конца строки или оператором, например ; или +. Делается это для того, чтобы, глядя всего на одну строку, знать, есть ли у команды продолжение на следующей строке или нет. Тем самым для понимания надо прочитать всего одну строку вместо двух, что экономит время. А отсутствие ; в конце команды может привести к ошибкам исполнения.
74
+ ### Always End Lines with Operators or Semicolons
42
75
 
43
- ```Typescript
44
- /**
45
- * Оператор в конце строки
46
- */
76
+ Lines should always end with an operator or semicolon to make it clear whether the statement continues. This saves reading time and prevents execution errors.
47
77
 
48
- // Плохо. Глядя на первую строку, не понятно, это конец команды или надо искать продолжение
78
+ ```typescript
79
+ // Bad - unclear if statement continues
49
80
  let sample = sample.sample.sample
50
81
  + sample.sample.sample;
51
82
 
52
- // Хорошо. Глядя на первую строку, видно, что команда не заканчивается, и стоит искать продолжение на следующей
83
+ // Good - operator at end shows continuation
53
84
  let sample = sample.sample.sample +
54
85
  sample.sample.sample;
55
-
56
- /**
57
- * Знак конца строки
58
- */
59
-
60
- // Плохо. Выведет 2,2, хотя ожидается 0,2
61
- var a = 1, b = 0
62
- if(a>b) a=b
63
- -b > 0 ? b=1 : b=2;
64
- alert([a,b])
65
-
66
- // Плохо, выдаст ошибку исполнения
67
- var i,s
68
- s="here is a string"
69
- i=0
70
- /[a-z]/g.exec(s)
71
-
72
86
  ```
73
87
 
74
- ### Фигурные скобки в if
75
-
76
- Даже если после блока if идет всего одна команда, фигурные скобки все равно ставить обязательно.
77
- Во-первых, вы сэкономите время себе же в будущем, когда понадобится срочно дополнить условие.
78
- Во-вторых, очень часто люди не замечают, что строка относится к условию if, и при рефакторинге или удалении строки забывают про if, из-за чего if начинает влиять на другую строку кода.
88
+ ### Always Use Braces for If Statements
79
89
 
80
- ```Typescript
81
- // Плохо
82
- if (n > 10) alert("Плохо");
90
+ Even for single-line statements, always use braces. This prevents bugs during refactoring and improves code clarity.
83
91
 
84
- // Плохо
85
- if (n > 10)
86
- alert("Плохо");
92
+ ```typescript
93
+ // Bad
94
+ if (n > 10) alert("Bad");
87
95
 
88
- // Хорошо
96
+ // Good
89
97
  if (n > 10) {
90
- alert("Хорошо");
98
+ alert("Good");
91
99
  }
92
100
  ```
93
101
 
94
- ### Используйте двойные кавычки
102
+ ### Use Double Quotes and Template Literals
95
103
 
96
- Изначально в более взрослых языках используются " для написания строк, в JS для более простого экранирования было принято писать '. Так было проще для JS-разработчиков. Но теперь существуют шаблонные строки, которые справляются с этой задачей намного лучше. К тому же коллегам с бэкенда будет проще понимать ваш код в случае необходимости.
104
+ Use double quotes for consistency with other languages, and template literals for string interpolation.
97
105
 
98
- ```Typescript
99
- const message = "булочек";
106
+ ```typescript
107
+ const message = "rolls";
100
108
  const count = 5;
101
109
 
102
- // Плохо
103
- const data = 'Отправляю "бабушке" ' + count * 5 + ' ' + message + '.';
110
+ // Bad
111
+ const data = 'Sending "grandma" ' + count * 5 + ' ' + message + '.';
104
112
 
105
- // Хорошо
106
- const data = `Отправляю "бабушке" ${count * 5} ${message}.`;
113
+ // Good
114
+ const data = `Sending "grandma" ${count * 5} ${message}.`;
107
115
  ```
108
116
 
109
- ### Длина строки 120 символов и отступ 4 пробела
117
+ ### Line Length: 120 Characters, Indent: 4 Spaces
110
118
 
111
- У всех разработчиков разные мониторы: у кого-то большие, у кого-то маленькие, а кто-то вообще через консоль работает. Поэтому оптимальным размером строки является 120 символов. А использование 4 пробелов для отступа является оптимальным решением для определения уровня вложенности. Некоторые предпочитают использовать 2 пробела для того, чтобы на одну строку больше влезло, но это является плохой практикой, т.к. увеличивает нагрузку на глаза при определении уровня вложенности. Вместо того чтобы впихивать на одну строку больше кода, лучше использовать более удачное форматирование, например, писать более простые функции и использовать "функциональный" стиль для цепочек методов объекта.
119
+ Optimal line length is 120 characters for readability across different monitors. Use 4-space indentation for clear nesting levels.
112
120
 
113
- Для вдохновения предлагаю взглянуть на [ядро Linux](https://github.com/torvalds/linux/blob/master/kernel/acct.c). Посмотрите, как просто написан такой огромный и сложный продукт, а длина строки всего 80 символов.
121
+ ## Security
114
122
 
115
- ```Typescript
116
- export class Tabs extends Base {
117
- // ...
118
- private onTabClick(tab: Tab): void {
123
+ For security concerns, please see our [Security Policy](./SECURITY.md).
119
124
 
120
- if (tab.active) {
125
+ ## Contributing
121
126
 
122
- if (!this._slotElement
123
- .assignedNodes()
124
- .some((node: Node) => node instanceof Tab && node.active === true)) {
127
+ Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
125
128
 
126
- const offset = tab.offsetLeft - tab.parentElement!.offsetLeft;
127
- const width = tab.offsetWidth;
128
- this._lineElement.style.marginLeft = `${offset + width / 2}px`;
129
- this._lineElement.style.width = `0`;
129
+ ## License
130
130
 
131
- }
132
- }
133
- }
134
- }
135
- ```
131
+ MIT © Eugene Labutin
132
+
133
+ ## Links
134
+
135
+ - [npm package](https://www.npmjs.com/package/@labeg/code-style)
136
+ - [GitHub repository](https://github.com/LabEG/code-style)
137
+ - [Issue tracker](https://github.com/LabEG/code-style/issues)
138
+ - [Changelog](./CHANGELOG.md)
package/package.json CHANGED
@@ -1,12 +1,33 @@
1
1
  {
2
2
  "name": "@labeg/code-style",
3
- "version": "6.8.0",
3
+ "version": "6.10.0",
4
4
  "author": "Eugene Labutin",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/LabEG/code-style#readme",
7
7
  "description": "Code styles rules for difference linters, for create best code quality",
8
8
  "type": "module",
9
9
  "main": "eslint.config.js",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./eslint.config.js",
13
+ "require": "./eslint.config.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "eslint.config.js",
19
+ ".editorconfig",
20
+ ".remarkrc",
21
+ ".prettierrc",
22
+ "LICENSE",
23
+ "README.md",
24
+ "SECURITY.md",
25
+ "CHANGELOG.md"
26
+ ],
27
+ "engines": {
28
+ "node": ">=18.0.0",
29
+ "npm": ">=9.0.0"
30
+ },
10
31
  "repository": {
11
32
  "type": "git",
12
33
  "url": "git+https://github.com/LabEG/code-style.git"