voss-node-configs 1.0.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.
- package/README.md +119 -0
- package/eslint/back-end.js +13 -0
- package/eslint/base.js +35 -0
- package/eslint/front-end.js +13 -0
- package/eslint/node.js +15 -0
- package/package.json +27 -0
- package/typescript/back-end/tsconfig.json +3 -0
- package/typescript/back-end.json +10 -0
- package/typescript/base.json +39 -0
- package/typescript/common.json +9 -0
- package/typescript/front-end.base.json +15 -0
- package/typescript/front-end.build.json +9 -0
- package/typescript/front-end.dev.json +8 -0
- package/typescript/front-end.node.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Node Configs Voss
|
|
2
|
+
|
|
3
|
+
Shared TypeScript and ESLint configurations for Node.js projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev node-configs-voss
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## TypeScript Configs
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
// tsconfig.json
|
|
17
|
+
{
|
|
18
|
+
"extends": "node-configs-voss/typescript/base"
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Available Configs
|
|
23
|
+
|
|
24
|
+
- `typescript/base` - Base TypeScript configuration
|
|
25
|
+
- `typescript/common` - Common TypeScript configuration
|
|
26
|
+
- `typescript/back-end` - Backend-specific TypeScript configuration
|
|
27
|
+
- `typescript/front-end-base` - Frontend base TypeScript configuration
|
|
28
|
+
- `typescript/front-end-dev` - Frontend development TypeScript configuration
|
|
29
|
+
- `typescript/front-end-build` - Frontend build TypeScript configuration
|
|
30
|
+
- `typescript/front-end-node` - Frontend Node.js TypeScript configuration
|
|
31
|
+
|
|
32
|
+
## ESLint Configs
|
|
33
|
+
|
|
34
|
+
### Installation
|
|
35
|
+
|
|
36
|
+
You'll also need to install the required ESLint dependencies:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install --save-dev eslint@^9.0.0 @typescript-eslint/eslint-plugin@^7.0.0 @typescript-eslint/parser@^7.0.0
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Usage
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// eslint.config.js
|
|
46
|
+
module.exports = {
|
|
47
|
+
extends: ['node-configs-voss/eslint/base'],
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Available Configs
|
|
52
|
+
|
|
53
|
+
- `eslint/base` - Base ESLint configuration with TypeScript support
|
|
54
|
+
- `eslint/back-end` - Backend-specific ESLint configuration
|
|
55
|
+
- `eslint/front-end` - Frontend-specific ESLint configuration
|
|
56
|
+
- `eslint/node` - Node.js specific ESLint configuration
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
### Backend Project
|
|
61
|
+
|
|
62
|
+
**tsconfig.json:**
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"extends": "node-configs-voss/typescript/back-end"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**eslint.config.js:**
|
|
70
|
+
```javascript
|
|
71
|
+
module.exports = {
|
|
72
|
+
extends: ['node-configs-voss/eslint/back-end'],
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Frontend Project
|
|
77
|
+
|
|
78
|
+
**tsconfig.json:**
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"extends": "node-configs-voss/typescript/front-end-base"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**eslint.config.js:**
|
|
86
|
+
```javascript
|
|
87
|
+
module.exports = {
|
|
88
|
+
extends: ['node-configs-voss/eslint/front-end'],
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration Details
|
|
93
|
+
|
|
94
|
+
### TypeScript Configs
|
|
95
|
+
|
|
96
|
+
- **base**: Strict TypeScript configuration with modern ES features
|
|
97
|
+
- **common**: Common settings for shared libraries
|
|
98
|
+
- **back-end**: Optimized for Node.js backend development
|
|
99
|
+
- **front-end-***: Various frontend configurations for different build targets
|
|
100
|
+
|
|
101
|
+
### ESLint Configs
|
|
102
|
+
|
|
103
|
+
- **base**: Comprehensive TypeScript linting with modern JavaScript rules
|
|
104
|
+
- **back-end**: Allows console usage and CommonJS requires
|
|
105
|
+
- **front-end**: Warns about console usage and enforces ES modules
|
|
106
|
+
- **node**: Node.js specific rules with process.exit prevention
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
To contribute to this package:
|
|
111
|
+
|
|
112
|
+
1. Make changes to the config files
|
|
113
|
+
2. Test locally with a sample project
|
|
114
|
+
3. Update version in package.json
|
|
115
|
+
4. Publish to npm
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['./base.js'],
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
es2022: true,
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
// Backend-specific rules
|
|
9
|
+
'no-console': 'off', // Allow console in backend
|
|
10
|
+
'@typescript-eslint/no-require-imports': 'off', // Allow require() in backend
|
|
11
|
+
'global-require': 'off', // Allow require() anywhere in backend
|
|
12
|
+
},
|
|
13
|
+
};
|
package/eslint/base.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
'eslint:recommended',
|
|
4
|
+
'@typescript-eslint/recommended',
|
|
5
|
+
'@typescript-eslint/recommended-requiring-type-checking',
|
|
6
|
+
],
|
|
7
|
+
parser: '@typescript-eslint/parser',
|
|
8
|
+
parserOptions: {
|
|
9
|
+
ecmaVersion: 'latest',
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
project: './tsconfig.json',
|
|
12
|
+
},
|
|
13
|
+
plugins: ['@typescript-eslint'],
|
|
14
|
+
rules: {
|
|
15
|
+
// Base rules for all projects
|
|
16
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
17
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
18
|
+
'@typescript-eslint/prefer-const': 'error',
|
|
19
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
20
|
+
'prefer-const': 'error',
|
|
21
|
+
'no-var': 'error',
|
|
22
|
+
'no-console': 'off', // Allow console by default, can be overridden
|
|
23
|
+
'no-debugger': 'error',
|
|
24
|
+
'no-duplicate-imports': 'error',
|
|
25
|
+
'no-unreachable': 'error',
|
|
26
|
+
'prefer-arrow-callback': 'error',
|
|
27
|
+
'prefer-template': 'error',
|
|
28
|
+
'template-curly-spacing': 'error',
|
|
29
|
+
'object-curly-spacing': ['error', 'always'],
|
|
30
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
31
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
32
|
+
'semi': ['error', 'always'],
|
|
33
|
+
'quotes': ['error', 'single', { 'avoidEscape': true }],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['./base.js'],
|
|
3
|
+
env: {
|
|
4
|
+
browser: true,
|
|
5
|
+
es2022: true,
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
// Frontend-specific rules
|
|
9
|
+
'no-console': 'warn', // Warn about console in frontend
|
|
10
|
+
'@typescript-eslint/no-require-imports': 'error', // Disallow require() in frontend
|
|
11
|
+
'global-require': 'error', // Disallow require() in frontend
|
|
12
|
+
},
|
|
13
|
+
};
|
package/eslint/node.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['./base.js'],
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
es2022: true,
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
// Node.js specific rules
|
|
9
|
+
'no-console': 'off', // Allow console in Node.js
|
|
10
|
+
'@typescript-eslint/no-require-imports': 'off', // Allow require() in Node.js
|
|
11
|
+
'global-require': 'off', // Allow require() anywhere in Node.js
|
|
12
|
+
'no-process-exit': 'error', // Prevent process.exit() usage
|
|
13
|
+
'no-sync': 'warn', // Warn about synchronous methods
|
|
14
|
+
},
|
|
15
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "voss-node-configs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared TypeScript and ESLint configs for Node.js projects",
|
|
5
|
+
"exports": {
|
|
6
|
+
"typescript/base": "./typescript/base.json",
|
|
7
|
+
"typescript/common": "./typescript/common.json",
|
|
8
|
+
"typescript/back-end": "./typescript/back-end/tsconfig.json",
|
|
9
|
+
"typescript/front-end-base": "./typescript/front-end.base.json",
|
|
10
|
+
"typescript/front-end-dev": "./typescript/front-end.dev.json",
|
|
11
|
+
"typescript/front-end-build": "./typescript/front-end.build.json",
|
|
12
|
+
"typescript/front-end-node": "./typescript/front-end.node.json",
|
|
13
|
+
"eslint/base": "./eslint/base.js",
|
|
14
|
+
"eslint/back-end": "./eslint/back-end.js",
|
|
15
|
+
"eslint/front-end": "./eslint/front-end.js",
|
|
16
|
+
"eslint/node": "./eslint/node.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"typescript/",
|
|
20
|
+
"eslint/"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"private": false,
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Interop Constraints */
|
|
6
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
7
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
8
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
9
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
10
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
11
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
12
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
13
|
+
|
|
14
|
+
/* Type Checking */
|
|
15
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
16
|
+
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
17
|
+
"strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
18
|
+
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
19
|
+
"strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
20
|
+
"strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
21
|
+
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
22
|
+
"noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
23
|
+
"useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
24
|
+
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
25
|
+
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
26
|
+
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
27
|
+
"exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
28
|
+
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
29
|
+
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
30
|
+
"noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
31
|
+
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
32
|
+
"noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
33
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
34
|
+
"allowUnreachableCode": false, /* Disable error reporting for unreachable code. */
|
|
35
|
+
|
|
36
|
+
/* Completeness */
|
|
37
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"types": ["vite/client"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"preserveSymlinks": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"types": ["node"]
|
|
16
|
+
}
|
|
17
|
+
}
|