@labeg/code-style 6.9.0 → 6.10.1
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/CHANGELOG.md +20 -0
- package/README.md +89 -86
- 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.1] - 2025-11-15
|
|
6
|
+
|
|
7
|
+
### ⚙️ Miscellaneous Tasks
|
|
8
|
+
|
|
9
|
+
- Remove .npmignore file
|
|
10
|
+
|
|
11
|
+
# Changelog
|
|
12
|
+
|
|
13
|
+
All notable changes to this project will be documented in this file.
|
|
14
|
+
|
|
15
|
+
## [6.10.0] - 2025-11-15
|
|
16
|
+
|
|
17
|
+
### 🚀 Features
|
|
18
|
+
|
|
19
|
+
- Add issue templates for bug reports and feature requests, enhance contributing guidelines
|
|
20
|
+
|
|
21
|
+
# Changelog
|
|
22
|
+
|
|
23
|
+
All notable changes to this project will be documented in this file.
|
|
24
|
+
|
|
5
25
|
## [6.9.0] - 2025-11-15
|
|
6
26
|
|
|
7
27
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,135 +1,138 @@
|
|
|
1
1
|
# CodeStyle
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
3
5
|

|
|
6
|
+

|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### ESLint 9+ (Flat Config)
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
47
|
+
### Next.js Projects
|
|
27
48
|
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
75
|
-
|
|
76
|
-
Даже если после блока if идет всего одна команда, фигурные скобки все равно ставить обязательно.
|
|
77
|
-
Во-первых, вы сэкономите время себе же в будущем, когда понадобится срочно дополнить условие.
|
|
78
|
-
Во-вторых, очень часто люди не замечают, что строка относится к условию if, и при рефакторинге или удалении строки забывают про if, из-за чего if начинает влиять на другую строку кода.
|
|
88
|
+
### Always Use Braces for If Statements
|
|
79
89
|
|
|
80
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
104
|
+
Use double quotes for consistency with other languages, and template literals for string interpolation.
|
|
97
105
|
|
|
98
|
-
```
|
|
99
|
-
const message = "
|
|
106
|
+
```typescript
|
|
107
|
+
const message = "rolls";
|
|
100
108
|
const count = 5;
|
|
101
109
|
|
|
102
|
-
//
|
|
103
|
-
const data = '
|
|
110
|
+
// Bad
|
|
111
|
+
const data = 'Sending "grandma" ' + count * 5 + ' ' + message + '.';
|
|
104
112
|
|
|
105
|
-
//
|
|
106
|
-
const data =
|
|
113
|
+
// Good
|
|
114
|
+
const data = `Sending "grandma" ${count * 5} ${message}.`;
|
|
107
115
|
```
|
|
108
116
|
|
|
109
|
-
###
|
|
117
|
+
### Line Length: 120 Characters, Indent: 4 Spaces
|
|
110
118
|
|
|
111
|
-
|
|
119
|
+
Optimal line length is 120 characters for readability across different monitors. Use 4-space indentation for clear nesting levels.
|
|
112
120
|
|
|
113
|
-
|
|
121
|
+
## Security
|
|
114
122
|
|
|
115
|
-
|
|
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
|
-
|
|
125
|
+
## Contributing
|
|
121
126
|
|
|
122
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "6.10.1",
|
|
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"
|