@geprom/eslint-prettier-sapient 1.0.3 → 1.0.5
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/LICENSE +21 -21
- package/README.md +78 -116
- package/index.js +67 -66
- package/package.json +53 -53
- package/prettier-config.js +18 -18
- package/setup.js +163 -163
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 GEPROM
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GEPROM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,116 +1,78 @@
|
|
|
1
|
-
# @geprom/eslint-prettier-sapient
|
|
2
|
-
|
|
3
|
-
ESLint and Prettier configuration for Geprom Sapient projects with support for both camelCase and snake_case naming conventions.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i @geprom/eslint-prettier-sapient
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
myCustomGlobal: 'readonly',
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### ESLint Rules
|
|
85
|
-
|
|
86
|
-
- **camelcase**: Flexible naming - accepts both camelCase and snake_case patterns
|
|
87
|
-
- **jsx-a11y/href-no-hash**: Disabled
|
|
88
|
-
- **react/jsx-filename-extension**: Warns for .js files (allows .jsx)
|
|
89
|
-
- **max-len**: 100 character limit with exceptions for comments, URLs, and strings
|
|
90
|
-
- **react/prop-types**: Warning level
|
|
91
|
-
- **no-unused-vars**: Ignores variables starting with underscore
|
|
92
|
-
|
|
93
|
-
### Prettier Options
|
|
94
|
-
|
|
95
|
-
- **printWidth**: 100 characters
|
|
96
|
-
- **singleQuote**: true
|
|
97
|
-
- **trailingComma**: 'es5'
|
|
98
|
-
- **bracketSpacing**: true
|
|
99
|
-
- **semi**: true
|
|
100
|
-
- **useTabs**: false
|
|
101
|
-
- **tabWidth**: 2 spaces
|
|
102
|
-
- **arrowParens**: 'always'
|
|
103
|
-
|
|
104
|
-
## Extending the Configuration
|
|
105
|
-
|
|
106
|
-
You can extend or override rules in your project's `.eslintrc.js`:
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
module.exports = {
|
|
110
|
-
extends: ['@geprom/eslint-prettier-sapient'],
|
|
111
|
-
rules: {
|
|
112
|
-
'max-len': ['warn', { code: 120 }], // Override max line length
|
|
113
|
-
'no-console': 'warn', // Add custom rule
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
```
|
|
1
|
+
# @geprom/eslint-prettier-sapient
|
|
2
|
+
|
|
3
|
+
ESLint and Prettier configuration for Geprom Sapient projects with support for both camelCase and snake_case naming conventions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @geprom/eslint-prettier-sapient
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✅ Airbnb ESLint ruleset
|
|
14
|
+
- ✅ Prettier integration
|
|
15
|
+
- ✅ Both camelCase and snake_case naming support
|
|
16
|
+
- ✅ Preconfigured globals: `DbCon`, `DbQuery`, `logger`
|
|
17
|
+
|
|
18
|
+
## Configuration Details
|
|
19
|
+
|
|
20
|
+
### Supported Naming Conventions
|
|
21
|
+
|
|
22
|
+
Both naming styles are accepted without warnings:
|
|
23
|
+
|
|
24
|
+
- `someFunction` (camelCase)
|
|
25
|
+
- `some_function` (snake_case)
|
|
26
|
+
|
|
27
|
+
### Application Globals
|
|
28
|
+
|
|
29
|
+
These globals are pre-declared and don't require imports, any additional global variable available in Sapient should :
|
|
30
|
+
|
|
31
|
+
- `DbCon` - Database connection class
|
|
32
|
+
- `DbQuery` - Database query class
|
|
33
|
+
- `logger` - Logger instance
|
|
34
|
+
|
|
35
|
+
To extend with additional globals:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
module.exports = {
|
|
39
|
+
extends: ['@geprom/eslint-prettier-sapient'],
|
|
40
|
+
globals: {
|
|
41
|
+
myCustomGlobal: 'readonly',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### ESLint Rules
|
|
47
|
+
|
|
48
|
+
- **camelcase**: Flexible naming - accepts both camelCase and snake_case patterns
|
|
49
|
+
- **jsx-a11y/href-no-hash**: Disabled
|
|
50
|
+
- **react/jsx-filename-extension**: Warns for .js files (allows .jsx)
|
|
51
|
+
- **max-len**: 100 character limit with exceptions for comments, URLs, and strings
|
|
52
|
+
- **react/prop-types**: Warning level
|
|
53
|
+
- **no-unused-vars**: Ignores variables starting with underscore
|
|
54
|
+
|
|
55
|
+
### Prettier Options
|
|
56
|
+
|
|
57
|
+
- **printWidth**: 100 characters
|
|
58
|
+
- **singleQuote**: true
|
|
59
|
+
- **trailingComma**: 'es5'
|
|
60
|
+
- **bracketSpacing**: true
|
|
61
|
+
- **semi**: true
|
|
62
|
+
- **useTabs**: false
|
|
63
|
+
- **tabWidth**: 2 spaces
|
|
64
|
+
- **arrowParens**: 'always'
|
|
65
|
+
|
|
66
|
+
## Extending the Configuration
|
|
67
|
+
|
|
68
|
+
You can extend or override rules in your project's `.eslintrc.js`:
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
module.exports = {
|
|
72
|
+
extends: ['@geprom/eslint-prettier-sapient'],
|
|
73
|
+
rules: {
|
|
74
|
+
'max-len': ['warn', { code: 120 }], // Override max line length
|
|
75
|
+
'no-console': 'warn', // Add custom rule
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
```
|
package/index.js
CHANGED
|
@@ -1,66 +1,67 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: ["airbnb", "plugin:prettier/recommended", "prettier"],
|
|
3
|
-
env: {
|
|
4
|
-
browser: true,
|
|
5
|
-
commonjs: true,
|
|
6
|
-
es6: true,
|
|
7
|
-
jest: true,
|
|
8
|
-
node: true,
|
|
9
|
-
},
|
|
10
|
-
parser: "espree",
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaVersion: 2020,
|
|
13
|
-
sourceType: "module",
|
|
14
|
-
ecmaFeatures: {
|
|
15
|
-
jsx: true,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
globals: {
|
|
19
|
-
DbCon: "readonly",
|
|
20
|
-
DbQuery: "readonly",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ["airbnb", "plugin:prettier/recommended", "prettier"],
|
|
3
|
+
env: {
|
|
4
|
+
browser: true,
|
|
5
|
+
commonjs: true,
|
|
6
|
+
es6: true,
|
|
7
|
+
jest: true,
|
|
8
|
+
node: true,
|
|
9
|
+
},
|
|
10
|
+
parser: "espree",
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
sourceType: "module",
|
|
14
|
+
ecmaFeatures: {
|
|
15
|
+
jsx: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
globals: {
|
|
19
|
+
DbCon: "readonly",
|
|
20
|
+
DbQuery: "readonly",
|
|
21
|
+
execute: "readonly",
|
|
22
|
+
logger: "readonly",
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
camelcase: [
|
|
26
|
+
"warn",
|
|
27
|
+
{
|
|
28
|
+
properties: "never",
|
|
29
|
+
ignoreDestructuring: true,
|
|
30
|
+
allow: ["^[a-z]+(_[a-z]+)*$", "^[a-zA-Z]+([A-Z][a-z]+)*$", "^[a-z]+(_([a-z]+|[A-Z]+))*$"],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
"jsx-a11y/href-no-hash": ["off"],
|
|
34
|
+
"react/jsx-filename-extension": [
|
|
35
|
+
"warn",
|
|
36
|
+
{
|
|
37
|
+
extensions: [".js", ".jsx"],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
"max-len": [
|
|
41
|
+
"warn",
|
|
42
|
+
{
|
|
43
|
+
code: 100,
|
|
44
|
+
tabWidth: 2,
|
|
45
|
+
comments: 100,
|
|
46
|
+
ignoreComments: false,
|
|
47
|
+
ignoreTrailingComments: true,
|
|
48
|
+
ignoreUrls: true,
|
|
49
|
+
ignoreStrings: true,
|
|
50
|
+
ignoreTemplateLiterals: true,
|
|
51
|
+
ignoreRegExpLiterals: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
"react/prop-types": [1],
|
|
55
|
+
"no-unused-vars": [
|
|
56
|
+
"warn",
|
|
57
|
+
{
|
|
58
|
+
argsIgnorePattern: "^_",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
settings: {
|
|
63
|
+
react: {
|
|
64
|
+
version: "detect",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geprom/eslint-prettier-sapient",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "ESLint and Prettier configuration for Geprom Sapient projects with snake_case and camelCase support",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"postinstall": "node setup.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"index.js",
|
|
11
|
-
"setup.js",
|
|
12
|
-
"prettier-config.js"
|
|
13
|
-
],
|
|
14
|
-
"keywords": [
|
|
15
|
-
"eslint",
|
|
16
|
-
"eslintconfig",
|
|
17
|
-
"prettier",
|
|
18
|
-
"airbnb",
|
|
19
|
-
"react",
|
|
20
|
-
"code-style",
|
|
21
|
-
"linter"
|
|
22
|
-
],
|
|
23
|
-
"author": "GEPROM",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"eslint": "^8.0.0",
|
|
27
|
-
"prettier": "^2.8.0",
|
|
28
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
29
|
-
"eslint-config-prettier": "^8.5.0",
|
|
30
|
-
"eslint-plugin-import": "^2.26.0",
|
|
31
|
-
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
32
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
33
|
-
"eslint-plugin-react": "^7.32.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"eslint": "^8.0.0",
|
|
37
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
38
|
-
"eslint-config-prettier": "^8.5.0",
|
|
39
|
-
"eslint-plugin-import": "^2.26.0",
|
|
40
|
-
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
41
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
42
|
-
"eslint-plugin-react": "^7.32.0",
|
|
43
|
-
"prettier": "^2.8.0"
|
|
44
|
-
},
|
|
45
|
-
"repository": {
|
|
46
|
-
"type": "git",
|
|
47
|
-
"url": "git+https://github.com/GEPROM/eslint-prettier-geprom-sapient.git"
|
|
48
|
-
},
|
|
49
|
-
"bugs": {
|
|
50
|
-
"url": "https://github.com/GEPROM/eslint-prettier-geprom-sapient/issues"
|
|
51
|
-
},
|
|
52
|
-
"homepage": "https://github.com/GEPROM/eslint-prettier-geprom-sapient#readme"
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@geprom/eslint-prettier-sapient",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "ESLint and Prettier configuration for Geprom Sapient projects with snake_case and camelCase support",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node setup.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"setup.js",
|
|
12
|
+
"prettier-config.js"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"eslint",
|
|
16
|
+
"eslintconfig",
|
|
17
|
+
"prettier",
|
|
18
|
+
"airbnb",
|
|
19
|
+
"react",
|
|
20
|
+
"code-style",
|
|
21
|
+
"linter"
|
|
22
|
+
],
|
|
23
|
+
"author": "GEPROM",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"eslint": "^8.0.0",
|
|
27
|
+
"prettier": "^2.8.0",
|
|
28
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
29
|
+
"eslint-config-prettier": "^8.5.0",
|
|
30
|
+
"eslint-plugin-import": "^2.26.0",
|
|
31
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
32
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
33
|
+
"eslint-plugin-react": "^7.32.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"eslint": "^8.0.0",
|
|
37
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
38
|
+
"eslint-config-prettier": "^8.5.0",
|
|
39
|
+
"eslint-plugin-import": "^2.26.0",
|
|
40
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
41
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
42
|
+
"eslint-plugin-react": "^7.32.0",
|
|
43
|
+
"prettier": "^2.8.0"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/GEPROM/eslint-prettier-geprom-sapient.git"
|
|
48
|
+
},
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/GEPROM/eslint-prettier-geprom-sapient/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/GEPROM/eslint-prettier-geprom-sapient#readme"
|
|
53
|
+
}
|
package/prettier-config.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
printWidth: 100,
|
|
3
|
-
tabWidth: 2,
|
|
4
|
-
useTabs: false,
|
|
5
|
-
semi: true,
|
|
6
|
-
singleQuote: true,
|
|
7
|
-
quoteProps: "as-needed",
|
|
8
|
-
jsxSingleQuote: false,
|
|
9
|
-
trailingComma: "es5",
|
|
10
|
-
bracketSpacing: true,
|
|
11
|
-
bracketSameLine: false,
|
|
12
|
-
arrowParens: "always",
|
|
13
|
-
requirePragma: false,
|
|
14
|
-
insertPragma: false,
|
|
15
|
-
proseWrap: "preserve",
|
|
16
|
-
htmlWhitespaceSensitivity: "css",
|
|
17
|
-
endOfLine: "
|
|
18
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
printWidth: 100,
|
|
3
|
+
tabWidth: 2,
|
|
4
|
+
useTabs: false,
|
|
5
|
+
semi: true,
|
|
6
|
+
singleQuote: true,
|
|
7
|
+
quoteProps: "as-needed",
|
|
8
|
+
jsxSingleQuote: false,
|
|
9
|
+
trailingComma: "es5",
|
|
10
|
+
bracketSpacing: true,
|
|
11
|
+
bracketSameLine: false,
|
|
12
|
+
arrowParens: "always",
|
|
13
|
+
requirePragma: false,
|
|
14
|
+
insertPragma: false,
|
|
15
|
+
proseWrap: "preserve",
|
|
16
|
+
htmlWhitespaceSensitivity: "css",
|
|
17
|
+
endOfLine: "auto",
|
|
18
|
+
};
|
package/setup.js
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { spawn } = require("child_process");
|
|
6
|
-
|
|
7
|
-
// Get the root directory of the project that installed this package
|
|
8
|
-
// When installed via npm, this runs in node_modules, so we go up to find the project root
|
|
9
|
-
const projectRoot = path.resolve(__dirname, "../../..");
|
|
10
|
-
|
|
11
|
-
// Read the eslint configuration from this package
|
|
12
|
-
const eslintConfig = require("./index.js");
|
|
13
|
-
|
|
14
|
-
// Prettier configuration
|
|
15
|
-
const prettierConfig = require("./prettier-config.js");
|
|
16
|
-
|
|
17
|
-
// Create .eslintrc.js in the project root
|
|
18
|
-
const eslintrcPath = path.join(projectRoot, ".eslintrc.js");
|
|
19
|
-
const eslintrcContent = `module.exports = ${JSON.stringify(eslintConfig, null, 2)};`;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
fs.writeFileSync(eslintrcPath, eslintrcContent, "utf8");
|
|
23
|
-
console.log("✓ Created .eslintrc.js");
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error("Error creating .eslintrc.js:", error.message);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Create .prettierrc.js in the project root
|
|
29
|
-
const prettierrcPath = path.join(projectRoot, ".prettierrc.js");
|
|
30
|
-
const prettierrcContent = `module.exports = ${JSON.stringify(prettierConfig, null, 2)};`;
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
fs.writeFileSync(prettierrcPath, prettierrcContent, "utf8");
|
|
34
|
-
console.log("✓ Created .prettierrc.js");
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error("Error creating .prettierrc.js:", error.message);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Create .eslintignore if it doesn't exist
|
|
40
|
-
const eslintignorePath = path.join(projectRoot, ".eslintignore");
|
|
41
|
-
if (!fs.existsSync(eslintignorePath)) {
|
|
42
|
-
const eslintignoreContent = `node_modules/
|
|
43
|
-
dist/
|
|
44
|
-
build/
|
|
45
|
-
coverage/
|
|
46
|
-
.next/
|
|
47
|
-
out/
|
|
48
|
-
`;
|
|
49
|
-
try {
|
|
50
|
-
fs.writeFileSync(eslintignorePath, eslintignoreContent, "utf8");
|
|
51
|
-
console.log("✓ Created .eslintignore");
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error("Error creating .eslintignore:", error.message);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Create .prettierignore if it doesn't exist
|
|
58
|
-
const prettierignorePath = path.join(projectRoot, ".prettierignore");
|
|
59
|
-
if (!fs.existsSync(prettierignorePath)) {
|
|
60
|
-
const prettierignoreContent = `node_modules/
|
|
61
|
-
dist/
|
|
62
|
-
build/
|
|
63
|
-
coverage/
|
|
64
|
-
.next/
|
|
65
|
-
out/
|
|
66
|
-
package-lock.json
|
|
67
|
-
yarn.lock
|
|
68
|
-
`;
|
|
69
|
-
try {
|
|
70
|
-
fs.writeFileSync(prettierignorePath, prettierignoreContent, "utf8");
|
|
71
|
-
console.log("✓ Created .prettierignore");
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error("Error creating .prettierignore:", error.message);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Create .vscode/settings.json if it doesn't exist
|
|
78
|
-
const vscodeDir = path.join(projectRoot, ".vscode");
|
|
79
|
-
const vscodePath = path.join(vscodeDir, "settings.json");
|
|
80
|
-
if (!fs.existsSync(vscodePath)) {
|
|
81
|
-
const vscodeSettings = {
|
|
82
|
-
"eslint.enable": true,
|
|
83
|
-
"eslint.validate": ["javascript", "javascriptreact"],
|
|
84
|
-
"[javascript]": {
|
|
85
|
-
"editor.codeActionsOnSave": {
|
|
86
|
-
"source.fixAll.eslint": true,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
"[javascriptreact]": {
|
|
90
|
-
"editor.codeActionsOnSave": {
|
|
91
|
-
"source.fixAll.eslint": true,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
try {
|
|
96
|
-
// Create .vscode directory if it doesn't exist
|
|
97
|
-
if (!fs.existsSync(vscodeDir)) {
|
|
98
|
-
fs.mkdirSync(vscodeDir, { recursive: true });
|
|
99
|
-
}
|
|
100
|
-
fs.writeFileSync(vscodePath, JSON.stringify(vscodeSettings, null, 2), "utf8");
|
|
101
|
-
console.log("✓ Created .vscode/settings.json");
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.error("Error creating .vscode/settings.json:", error.message);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Function to run a command
|
|
108
|
-
function runCommand(command, args, description) {
|
|
109
|
-
return new Promise((resolve, reject) => {
|
|
110
|
-
console.log(`\n▶ ${description}...`);
|
|
111
|
-
const child = spawn(command, args, {
|
|
112
|
-
cwd: projectRoot,
|
|
113
|
-
stdio: "inherit",
|
|
114
|
-
shell: true,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
child.on("close", (code) => {
|
|
118
|
-
if (code === 0) {
|
|
119
|
-
console.log(`✓ ${description} completed`);
|
|
120
|
-
resolve();
|
|
121
|
-
} else {
|
|
122
|
-
console.warn(`⚠ ${description} exited with code ${code}`);
|
|
123
|
-
resolve(); // Don't reject, warn instead
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
child.on("error", (error) => {
|
|
128
|
-
console.error(`Error running ${description}:`, error.message);
|
|
129
|
-
resolve(); // Don't reject, warn instead
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Run prettier and eslint if they're available
|
|
135
|
-
async function formatAndLint() {
|
|
136
|
-
try {
|
|
137
|
-
// Try to run prettier
|
|
138
|
-
await runCommand(
|
|
139
|
-
"npx",
|
|
140
|
-
["prettier", "--write", "."],
|
|
141
|
-
"Formatting with Prettier"
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
// Try to run eslint with --fix
|
|
145
|
-
await runCommand("npx", ["eslint", ".", "--fix"], "Fixing with ESLint");
|
|
146
|
-
|
|
147
|
-
console.log("\n✓ Setup completed successfully!");
|
|
148
|
-
} catch (error) {
|
|
149
|
-
console.error("Error during formatting/linting:", error.message);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Only run if prettier and eslint are available in the project
|
|
154
|
-
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
155
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
156
|
-
formatAndLint().catch(() => {
|
|
157
|
-
console.log(
|
|
158
|
-
"\nNote: Prettier and ESLint will format files when run manually."
|
|
159
|
-
);
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
console.log("package.json not found. Skipping auto-formatting.");
|
|
163
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { spawn } = require("child_process");
|
|
6
|
+
|
|
7
|
+
// Get the root directory of the project that installed this package
|
|
8
|
+
// When installed via npm, this runs in node_modules, so we go up to find the project root
|
|
9
|
+
const projectRoot = path.resolve(__dirname, "../../..");
|
|
10
|
+
|
|
11
|
+
// Read the eslint configuration from this package
|
|
12
|
+
const eslintConfig = require("./index.js");
|
|
13
|
+
|
|
14
|
+
// Prettier configuration
|
|
15
|
+
const prettierConfig = require("./prettier-config.js");
|
|
16
|
+
|
|
17
|
+
// Create .eslintrc.js in the project root
|
|
18
|
+
const eslintrcPath = path.join(projectRoot, ".eslintrc.js");
|
|
19
|
+
const eslintrcContent = `module.exports = ${JSON.stringify(eslintConfig, null, 2)};`;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
fs.writeFileSync(eslintrcPath, eslintrcContent, "utf8");
|
|
23
|
+
console.log("✓ Created .eslintrc.js");
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("Error creating .eslintrc.js:", error.message);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Create .prettierrc.js in the project root
|
|
29
|
+
const prettierrcPath = path.join(projectRoot, ".prettierrc.js");
|
|
30
|
+
const prettierrcContent = `module.exports = ${JSON.stringify(prettierConfig, null, 2)};`;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
fs.writeFileSync(prettierrcPath, prettierrcContent, "utf8");
|
|
34
|
+
console.log("✓ Created .prettierrc.js");
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error("Error creating .prettierrc.js:", error.message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Create .eslintignore if it doesn't exist
|
|
40
|
+
const eslintignorePath = path.join(projectRoot, ".eslintignore");
|
|
41
|
+
if (!fs.existsSync(eslintignorePath)) {
|
|
42
|
+
const eslintignoreContent = `node_modules/
|
|
43
|
+
dist/
|
|
44
|
+
build/
|
|
45
|
+
coverage/
|
|
46
|
+
.next/
|
|
47
|
+
out/
|
|
48
|
+
`;
|
|
49
|
+
try {
|
|
50
|
+
fs.writeFileSync(eslintignorePath, eslintignoreContent, "utf8");
|
|
51
|
+
console.log("✓ Created .eslintignore");
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("Error creating .eslintignore:", error.message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Create .prettierignore if it doesn't exist
|
|
58
|
+
const prettierignorePath = path.join(projectRoot, ".prettierignore");
|
|
59
|
+
if (!fs.existsSync(prettierignorePath)) {
|
|
60
|
+
const prettierignoreContent = `node_modules/
|
|
61
|
+
dist/
|
|
62
|
+
build/
|
|
63
|
+
coverage/
|
|
64
|
+
.next/
|
|
65
|
+
out/
|
|
66
|
+
package-lock.json
|
|
67
|
+
yarn.lock
|
|
68
|
+
`;
|
|
69
|
+
try {
|
|
70
|
+
fs.writeFileSync(prettierignorePath, prettierignoreContent, "utf8");
|
|
71
|
+
console.log("✓ Created .prettierignore");
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error("Error creating .prettierignore:", error.message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Create .vscode/settings.json if it doesn't exist
|
|
78
|
+
const vscodeDir = path.join(projectRoot, ".vscode");
|
|
79
|
+
const vscodePath = path.join(vscodeDir, "settings.json");
|
|
80
|
+
if (!fs.existsSync(vscodePath)) {
|
|
81
|
+
const vscodeSettings = {
|
|
82
|
+
"eslint.enable": true,
|
|
83
|
+
"eslint.validate": ["javascript", "javascriptreact"],
|
|
84
|
+
"[javascript]": {
|
|
85
|
+
"editor.codeActionsOnSave": {
|
|
86
|
+
"source.fixAll.eslint": true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
"[javascriptreact]": {
|
|
90
|
+
"editor.codeActionsOnSave": {
|
|
91
|
+
"source.fixAll.eslint": true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
try {
|
|
96
|
+
// Create .vscode directory if it doesn't exist
|
|
97
|
+
if (!fs.existsSync(vscodeDir)) {
|
|
98
|
+
fs.mkdirSync(vscodeDir, { recursive: true });
|
|
99
|
+
}
|
|
100
|
+
fs.writeFileSync(vscodePath, JSON.stringify(vscodeSettings, null, 2), "utf8");
|
|
101
|
+
console.log("✓ Created .vscode/settings.json");
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("Error creating .vscode/settings.json:", error.message);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Function to run a command
|
|
108
|
+
function runCommand(command, args, description) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
console.log(`\n▶ ${description}...`);
|
|
111
|
+
const child = spawn(command, args, {
|
|
112
|
+
cwd: projectRoot,
|
|
113
|
+
stdio: "inherit",
|
|
114
|
+
shell: true,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
child.on("close", (code) => {
|
|
118
|
+
if (code === 0) {
|
|
119
|
+
console.log(`✓ ${description} completed`);
|
|
120
|
+
resolve();
|
|
121
|
+
} else {
|
|
122
|
+
console.warn(`⚠ ${description} exited with code ${code}`);
|
|
123
|
+
resolve(); // Don't reject, warn instead
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
child.on("error", (error) => {
|
|
128
|
+
console.error(`Error running ${description}:`, error.message);
|
|
129
|
+
resolve(); // Don't reject, warn instead
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Run prettier and eslint if they're available
|
|
135
|
+
async function formatAndLint() {
|
|
136
|
+
try {
|
|
137
|
+
// Try to run prettier
|
|
138
|
+
await runCommand(
|
|
139
|
+
"npx",
|
|
140
|
+
["prettier", "--write", "."],
|
|
141
|
+
"Formatting with Prettier"
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Try to run eslint with --fix
|
|
145
|
+
await runCommand("npx", ["eslint", ".", "--fix"], "Fixing with ESLint");
|
|
146
|
+
|
|
147
|
+
console.log("\n✓ Setup completed successfully!");
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error("Error during formatting/linting:", error.message);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Only run if prettier and eslint are available in the project
|
|
154
|
+
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
155
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
156
|
+
formatAndLint().catch(() => {
|
|
157
|
+
console.log(
|
|
158
|
+
"\nNote: Prettier and ESLint will format files when run manually."
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
console.log("package.json not found. Skipping auto-formatting.");
|
|
163
|
+
}
|