@vijayhardaha/dev-config 1.0.10 → 1.0.11
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 +2 -1
- package/package.json +7 -2
- package/src/commitlint/index.js +3 -3
- package/src/eslint/common.js +153 -44
- package/src/eslint/index.js +19 -14
- package/src/eslint/next.js +19 -15
- package/src/eslint/react.js +18 -14
- package/src/eslint/typescript.js +15 -11
- package/src/index.js +11 -3
- package/src/next-sitemap/index.js +11 -9
- package/src/prettier/index.js +5 -5
- package/src/stylelint/index.js +5 -5
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm install @vijayhardaha/dev-config --save-dev
|
|
|
25
25
|
### Install Required Packages
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npm install --save-dev eslint@9.39.4 @eslint/js@9.39.4 @eslint/compat @eslint/eslintrc eslint-config-prettier eslint-plugin-prettier globals prettier typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-import eslint-import-resolver-typescript
|
|
28
|
+
npm install --save-dev eslint@9.39.4 @eslint/js@9.39.4 @eslint/compat @eslint/eslintrc eslint-config-prettier eslint-plugin-prettier globals prettier typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-jsdoc eslint-plugin-import eslint-import-resolver-typescript
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Install Optional Packages
|
|
@@ -98,6 +98,7 @@ export default createConfig({
|
|
|
98
98
|
importOrder: true, // Enable import ordering
|
|
99
99
|
react: true, // Enable React rules
|
|
100
100
|
a11y: true // Enable accessibility rules
|
|
101
|
+
jsdoc: true // Enable JSDoc rules
|
|
101
102
|
});
|
|
102
103
|
```
|
|
103
104
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vijayhardaha/dev-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Reusable development configurations for Next.js + TypeScript projects",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Vijay Hardaha",
|
|
@@ -68,10 +68,11 @@
|
|
|
68
68
|
"eslint-config-prettier": "^10",
|
|
69
69
|
"eslint-import-resolver-typescript": "^4",
|
|
70
70
|
"eslint-plugin-import": "^2",
|
|
71
|
+
"eslint-plugin-jsdoc": "^62",
|
|
71
72
|
"eslint-plugin-jsx-a11y": "^6",
|
|
72
73
|
"eslint-plugin-prettier": "^5",
|
|
73
|
-
"eslint-plugin-react-hooks": "^7",
|
|
74
74
|
"eslint-plugin-react": "^7",
|
|
75
|
+
"eslint-plugin-react-hooks": "^7",
|
|
75
76
|
"globals": "^17",
|
|
76
77
|
"prettier": "^3",
|
|
77
78
|
"stylelint": "^17",
|
|
@@ -123,6 +124,9 @@
|
|
|
123
124
|
"eslint-plugin-jsx-a11y": {
|
|
124
125
|
"optional": true
|
|
125
126
|
},
|
|
127
|
+
"eslint-plugin-jsdoc": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
126
130
|
"eslint-plugin-prettier": {
|
|
127
131
|
"optional": false
|
|
128
132
|
},
|
|
@@ -165,6 +169,7 @@
|
|
|
165
169
|
"eslint-config-prettier": "^10.1.8",
|
|
166
170
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
167
171
|
"eslint-plugin-import": "^2.32.0",
|
|
172
|
+
"eslint-plugin-jsdoc": "^62.9.0",
|
|
168
173
|
"eslint-plugin-prettier": "^5.5.5",
|
|
169
174
|
"globals": "^17.4.0",
|
|
170
175
|
"husky": "^9.1.7",
|
package/src/commitlint/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Commitlint Configuration
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Enforce conventional commit message standards for consistent
|
|
6
6
|
* and meaningful Git commit history.
|
|
7
7
|
* Docs: https://commitlint.js.org/#/
|
|
8
|
-
*
|
|
8
|
+
* =====================================================================.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/** @type {import('@commitlint/types').UserConfig} */
|
package/src/eslint/common.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Eslint Common Configuration
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Shared setup for all ESLint configurations including common
|
|
6
6
|
* ignores, parser setup, and rule definitions.
|
|
7
|
-
* Docs:
|
|
8
|
-
*
|
|
7
|
+
* Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
|
|
8
|
+
* =====================================================================.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import path from 'node:path';
|
|
@@ -58,18 +58,21 @@ const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Returns the setup object containing shared utilities for ESLint configs.
|
|
61
|
-
*
|
|
61
|
+
*
|
|
62
|
+
* @returns {{ compat: FlatCompat, tsParser: typeof tsParser, __dirname: string }} Reusable setup utilities for ESLint configurations.
|
|
62
63
|
*/
|
|
63
64
|
export const setup = () => ({ compat, tsParser, __dirname });
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Global ignores configuration using ESLint's globalIgnores helper.
|
|
68
|
+
*
|
|
67
69
|
* @type {import('eslint').Linter.Config}
|
|
68
70
|
*/
|
|
69
71
|
export const commonIgnores = [globalIgnores(ignores)];
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Common parser configuration for TypeScript files.
|
|
75
|
+
*
|
|
73
76
|
* @type {{ parser: typeof tsParser }}
|
|
74
77
|
*/
|
|
75
78
|
export const commonParser = { parser: tsParser };
|
|
@@ -77,6 +80,7 @@ export const commonParser = { parser: tsParser };
|
|
|
77
80
|
/**
|
|
78
81
|
* Common language options for ESLint including ECMAScript version,
|
|
79
82
|
* source type, and global variables.
|
|
83
|
+
*
|
|
80
84
|
* @type {import('eslint').Linter.LanguageOptions}
|
|
81
85
|
*/
|
|
82
86
|
export const commonLanguageOptions = {
|
|
@@ -85,61 +89,166 @@ export const commonLanguageOptions = {
|
|
|
85
89
|
globals: { ...globals.browser, ...globals.node },
|
|
86
90
|
};
|
|
87
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Creates JSDoc rules for enforcing documentation on public/exported APIs.
|
|
94
|
+
*
|
|
95
|
+
* @param {boolean} [jsdoc] - Enable JSDoc rules.
|
|
96
|
+
*
|
|
97
|
+
* @returns {object} JSDoc ESLint rules object.
|
|
98
|
+
*/
|
|
99
|
+
export const jsdocRules = (jsdoc = true) =>
|
|
100
|
+
jsdoc
|
|
101
|
+
? {
|
|
102
|
+
// ---- JSDoc Rules for PUBLIC / EXPORTED APIs ----
|
|
103
|
+
'jsdoc/require-jsdoc': [
|
|
104
|
+
'error',
|
|
105
|
+
{
|
|
106
|
+
publicOnly: true,
|
|
107
|
+
require: {
|
|
108
|
+
FunctionDeclaration: true,
|
|
109
|
+
MethodDefinition: true,
|
|
110
|
+
ClassDeclaration: true,
|
|
111
|
+
ArrowFunctionExpression: true,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
|
|
116
|
+
// Descriptions must exist and be meaningful
|
|
117
|
+
'jsdoc/require-description': 'error',
|
|
118
|
+
'jsdoc/require-description-complete-sentence': ['error', { tags: ['param', 'returns'] }],
|
|
119
|
+
|
|
120
|
+
// Params must be fully documented
|
|
121
|
+
'jsdoc/require-param': 'error',
|
|
122
|
+
'jsdoc/require-param-name': 'error',
|
|
123
|
+
'jsdoc/require-param-description': 'error',
|
|
124
|
+
'jsdoc/require-param-type': 'error',
|
|
125
|
+
|
|
126
|
+
// Returns must be documented
|
|
127
|
+
'jsdoc/require-returns': 'error',
|
|
128
|
+
'jsdoc/require-returns-description': 'error',
|
|
129
|
+
'jsdoc/require-returns-type': 'error',
|
|
130
|
+
|
|
131
|
+
// Throws must be documented
|
|
132
|
+
'jsdoc/require-throws': 'error',
|
|
133
|
+
|
|
134
|
+
// Strict correctness
|
|
135
|
+
'jsdoc/check-tag-names': 'error',
|
|
136
|
+
'jsdoc/no-undefined-types': ['error', { definedTypes: ['JSX.Element'] }],
|
|
137
|
+
'jsdoc/valid-types': 'error',
|
|
138
|
+
|
|
139
|
+
// Enforce clean structure
|
|
140
|
+
'jsdoc/tag-lines': ['error', 'any', { startLines: 1, endLines: 0, applyToEndTag: true }],
|
|
141
|
+
|
|
142
|
+
'jsdoc/check-alignment': 'error',
|
|
143
|
+
'jsdoc/check-indentation': 'off',
|
|
144
|
+
|
|
145
|
+
// Optional but powerful for large teams
|
|
146
|
+
'jsdoc/sort-tags': [
|
|
147
|
+
'warn',
|
|
148
|
+
{ tagSequence: [{ tags: ['description'] }, { tags: ['param'] }, { tags: ['returns'] }] },
|
|
149
|
+
],
|
|
150
|
+
|
|
151
|
+
// Avoid useless docs
|
|
152
|
+
'jsdoc/no-types': 'off',
|
|
153
|
+
'jsdoc/informative-docs': 'warn',
|
|
154
|
+
|
|
155
|
+
// Enforce property docs in typedef-style (optional)
|
|
156
|
+
'jsdoc/require-property-description': 'warn',
|
|
157
|
+
}
|
|
158
|
+
: {};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Creates TypeScript-specific rules.
|
|
162
|
+
*
|
|
163
|
+
* @param {boolean} [typescript] - Enable TypeScript rules.
|
|
164
|
+
*
|
|
165
|
+
* @returns {object} TypeScript ESLint rules object.
|
|
166
|
+
*/
|
|
167
|
+
export const tsRules = (typescript = true) =>
|
|
168
|
+
typescript
|
|
169
|
+
? {
|
|
170
|
+
'@typescript-eslint/no-unused-vars': [
|
|
171
|
+
'error',
|
|
172
|
+
{
|
|
173
|
+
vars: 'all',
|
|
174
|
+
args: 'after-used',
|
|
175
|
+
varsIgnorePattern: '^_',
|
|
176
|
+
argsIgnorePattern: '^_',
|
|
177
|
+
ignoreRestSiblings: true,
|
|
178
|
+
caughtErrors: 'all',
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
}
|
|
182
|
+
: {};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Creates Prettier formatting rules.
|
|
186
|
+
*
|
|
187
|
+
* @param {boolean} [prettier] - Enable Prettier rules.
|
|
188
|
+
*
|
|
189
|
+
* @returns {object} Prettier ESLint rules object.
|
|
190
|
+
*/
|
|
191
|
+
export const prettierRules = (prettier = true) => (prettier ? { 'prettier/prettier': 'warn' } : {});
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Creates import order rules.
|
|
195
|
+
*
|
|
196
|
+
* @param {boolean} [importOrder] - Enable import order rules.
|
|
197
|
+
*
|
|
198
|
+
* @returns {object} Import order ESLint rules object.
|
|
199
|
+
*/
|
|
200
|
+
export const importOrderRules = (importOrder = true) =>
|
|
201
|
+
importOrder
|
|
202
|
+
? {
|
|
203
|
+
'import/order': [
|
|
204
|
+
'error',
|
|
205
|
+
{
|
|
206
|
+
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index', 'object'],
|
|
207
|
+
pathGroups: [
|
|
208
|
+
{ pattern: 'react', group: 'external', position: 'before' },
|
|
209
|
+
{ pattern: '@/**', group: 'internal', position: 'after' },
|
|
210
|
+
],
|
|
211
|
+
pathGroupsExcludedImportTypes: ['react'],
|
|
212
|
+
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
213
|
+
'newlines-between': 'always',
|
|
214
|
+
warnOnUnassignedImports: true,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
}
|
|
218
|
+
: {};
|
|
219
|
+
|
|
88
220
|
/**
|
|
89
221
|
* Creates a rules object based on the provided options.
|
|
90
|
-
*
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {boolean} [options.
|
|
93
|
-
* @param {boolean} [options.
|
|
94
|
-
* @
|
|
222
|
+
*
|
|
223
|
+
* @param {object} [options] - Configuration options.
|
|
224
|
+
* @param {boolean} [options.typescript] - Enable TypeScript-specific rules.
|
|
225
|
+
* @param {boolean} [options.importOrder] - Enable import order rules.
|
|
226
|
+
* @param {boolean} [options.prettier] - Enable Prettier integration.
|
|
227
|
+
* @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
|
|
228
|
+
*
|
|
229
|
+
* @returns {object} ESLint rules object.
|
|
95
230
|
*/
|
|
96
231
|
export const commonRules = (options = {}) => {
|
|
97
|
-
const { typescript = true, importOrder = true, prettier = true } = options;
|
|
232
|
+
const { typescript = true, importOrder = true, prettier = true, jsdoc = true } = options;
|
|
98
233
|
|
|
99
234
|
return {
|
|
100
235
|
// ---- TypeScript Rules ----
|
|
101
|
-
|
|
102
|
-
...(typescript && {
|
|
103
|
-
'@typescript-eslint/no-unused-vars': [
|
|
104
|
-
'error',
|
|
105
|
-
{
|
|
106
|
-
vars: 'all',
|
|
107
|
-
args: 'after-used',
|
|
108
|
-
varsIgnorePattern: '^_',
|
|
109
|
-
argsIgnorePattern: '^_',
|
|
110
|
-
ignoreRestSiblings: true,
|
|
111
|
-
caughtErrors: 'all',
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
}),
|
|
236
|
+
...tsRules(typescript),
|
|
115
237
|
|
|
116
238
|
// ---- Import Order Rules ----
|
|
117
|
-
|
|
118
|
-
...(importOrder && {
|
|
119
|
-
'import/order': [
|
|
120
|
-
'error',
|
|
121
|
-
{
|
|
122
|
-
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index', 'object'],
|
|
123
|
-
pathGroups: [
|
|
124
|
-
{ pattern: 'react', group: 'external', position: 'before' },
|
|
125
|
-
{ pattern: '@/**', group: 'internal', position: 'after' },
|
|
126
|
-
],
|
|
127
|
-
pathGroupsExcludedImportTypes: ['react'],
|
|
128
|
-
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
129
|
-
'newlines-between': 'always',
|
|
130
|
-
warnOnUnassignedImports: true,
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
}),
|
|
239
|
+
...importOrderRules(importOrder),
|
|
134
240
|
|
|
135
241
|
// ---- Prettier Integration ----
|
|
136
|
-
|
|
137
|
-
|
|
242
|
+
...prettierRules(prettier),
|
|
243
|
+
|
|
244
|
+
// ---- JSDoc Integration ----
|
|
245
|
+
...jsdocRules(jsdoc),
|
|
138
246
|
};
|
|
139
247
|
};
|
|
140
248
|
|
|
141
249
|
/**
|
|
142
250
|
* File patterns for ESLint configuration.
|
|
251
|
+
*
|
|
143
252
|
* @type {{ withTs: string[], withoutTs: string[] }}
|
|
144
253
|
*/
|
|
145
254
|
export const files = { withTs: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'], withoutTs: ['**/*.{js,jsx,mjs,cjs}'] };
|
package/src/eslint/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Eslint Configuration (Flat)
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Project-wide ESLint configuration for JavaScript.
|
|
6
6
|
* Enforces code quality and consistent styling.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
|
|
8
|
+
* Usage: npx eslint .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { defineConfig } from 'eslint/config';
|
|
@@ -17,19 +17,24 @@ const { compat } = setup();
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates an ESLint configuration object with optional features.
|
|
20
|
-
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {boolean} [options.
|
|
23
|
-
* @
|
|
20
|
+
*
|
|
21
|
+
* @param {object} [options] - Configuration options.
|
|
22
|
+
* @param {boolean} [options.prettier] - Enable Prettier integration.
|
|
23
|
+
* @param {boolean} [options.importOrder] - Enable import order rules.
|
|
24
|
+
* @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
|
|
25
|
+
*
|
|
26
|
+
* @returns {import('eslint').Linter.Config[]} ESLint configuration array.
|
|
24
27
|
*/
|
|
25
28
|
export const createConfig = (options = {}) => {
|
|
26
|
-
const { prettier = true, importOrder = true } = options;
|
|
29
|
+
const { prettier = true, importOrder = true, jsdoc = true } = options;
|
|
27
30
|
|
|
28
31
|
// ---- Extends Configs ----
|
|
29
32
|
// Build the extends array based on enabled features
|
|
30
|
-
const extendsConfigs = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const extendsConfigs = [
|
|
34
|
+
importOrder && 'plugin:import/recommended',
|
|
35
|
+
jsdoc && 'plugin:jsdoc/recommended',
|
|
36
|
+
prettier && 'plugin:prettier/recommended',
|
|
37
|
+
].filter(Boolean);
|
|
33
38
|
|
|
34
39
|
return defineConfig([
|
|
35
40
|
// ---- Global Ignores ----
|
|
@@ -66,7 +71,7 @@ export const createConfig = (options = {}) => {
|
|
|
66
71
|
],
|
|
67
72
|
// ---- Common Rules ----
|
|
68
73
|
// Apply shared rules based on options
|
|
69
|
-
...commonRules({ prettier, importOrder, typescript: false }),
|
|
74
|
+
...commonRules({ prettier, importOrder, typescript: false, jsdoc }),
|
|
70
75
|
},
|
|
71
76
|
},
|
|
72
77
|
]);
|
package/src/eslint/next.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Eslint Configuration (Flat)
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Project-wide ESLint configuration for Next.js, TypeScript, and
|
|
6
6
|
* React. Enforces code quality, accessibility, and consistent styling.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
|
|
8
|
+
* Usage: npx eslint .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { defineConfig } from 'eslint/config';
|
|
@@ -18,26 +18,30 @@ const { compat } = setup();
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates an ESLint configuration object for Next.js projects with TypeScript
|
|
20
20
|
* and React support.
|
|
21
|
-
*
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {boolean} [options.
|
|
24
|
-
* @param {boolean} [options.
|
|
25
|
-
* @param {boolean} [options.
|
|
26
|
-
* @
|
|
21
|
+
*
|
|
22
|
+
* @param {object} [options] - Configuration options.
|
|
23
|
+
* @param {boolean} [options.prettier] - Enable Prettier integration.
|
|
24
|
+
* @param {boolean} [options.react] - Enable React-specific rules.
|
|
25
|
+
* @param {boolean} [options.a11y] - Enable accessibility rules.
|
|
26
|
+
* @param {boolean} [options.importOrder] - Enable import order rules.
|
|
27
|
+
* @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
|
|
28
|
+
*
|
|
29
|
+
* @returns {import('eslint').Linter.Config[]} ESLint configuration array.
|
|
27
30
|
*/
|
|
28
31
|
export const createConfig = (options = {}) => {
|
|
29
|
-
const { prettier = true, react = true, a11y = true, importOrder = true } = options;
|
|
32
|
+
const { prettier = true, react = true, a11y = true, importOrder = true, jsdoc = true } = options;
|
|
30
33
|
|
|
31
34
|
// ---- Extends Configs ----
|
|
32
35
|
// Build the extends array based on enabled features
|
|
33
36
|
const extendsConfigs = [
|
|
34
|
-
'plugin:import/recommended',
|
|
35
37
|
'next/core-web-vitals',
|
|
36
38
|
'next/typescript',
|
|
37
39
|
react && 'plugin:react/recommended',
|
|
38
40
|
react && 'plugin:react-hooks/recommended',
|
|
39
|
-
a11y && 'plugin:jsx-a11y/recommended',
|
|
40
41
|
'plugin:@typescript-eslint/recommended',
|
|
42
|
+
'plugin:import/recommended',
|
|
43
|
+
a11y && 'plugin:jsx-a11y/recommended',
|
|
44
|
+
jsdoc && 'plugin:jsdoc/recommended',
|
|
41
45
|
prettier && 'plugin:prettier/recommended',
|
|
42
46
|
].filter(Boolean);
|
|
43
47
|
|
|
@@ -77,7 +81,7 @@ export const createConfig = (options = {}) => {
|
|
|
77
81
|
...(react && { 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }] }),
|
|
78
82
|
// ---- Common Rules ----
|
|
79
83
|
// Apply shared rules
|
|
80
|
-
...commonRules({ prettier, importOrder }),
|
|
84
|
+
...commonRules({ prettier, importOrder, jsdoc }),
|
|
81
85
|
},
|
|
82
86
|
},
|
|
83
87
|
]);
|
package/src/eslint/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Eslint Configuration (Flat)
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Project-wide ESLint configuration for React with TypeScript.
|
|
6
6
|
* Enforces code quality, accessibility, and consistent styling.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
|
|
8
|
+
* Usage: npx eslint .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { defineConfig } from 'eslint/config';
|
|
@@ -18,23 +18,27 @@ const { compat } = setup();
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates an ESLint configuration object for React projects with TypeScript
|
|
20
20
|
* support.
|
|
21
|
-
*
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {boolean} [options.
|
|
24
|
-
* @param {boolean} [options.
|
|
25
|
-
* @
|
|
21
|
+
*
|
|
22
|
+
* @param {object} [options] - Configuration options.
|
|
23
|
+
* @param {boolean} [options.prettier] - Enable Prettier integration.
|
|
24
|
+
* @param {boolean} [options.a11y] - Enable accessibility rules.
|
|
25
|
+
* @param {boolean} [options.importOrder] - Enable import order rules.
|
|
26
|
+
* @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
|
|
27
|
+
*
|
|
28
|
+
* @returns {import('eslint').Linter.Config[]} ESLint configuration array.
|
|
26
29
|
*/
|
|
27
30
|
export const createConfig = (options = {}) => {
|
|
28
|
-
const { prettier = true, a11y = true, importOrder = true } = options;
|
|
31
|
+
const { prettier = true, a11y = true, importOrder = true, jsdoc = true } = options;
|
|
29
32
|
|
|
30
33
|
// ---- Extends Configs ----
|
|
31
34
|
// Build the extends array based on enabled features
|
|
32
35
|
const extendsConfigs = [
|
|
33
|
-
'plugin:import/recommended',
|
|
34
36
|
'plugin:react/recommended',
|
|
35
37
|
'plugin:react-hooks/recommended',
|
|
36
|
-
a11y && 'plugin:jsx-a11y/recommended',
|
|
37
38
|
'plugin:@typescript-eslint/recommended',
|
|
39
|
+
'plugin:import/recommended',
|
|
40
|
+
a11y && 'plugin:jsx-a11y/recommended',
|
|
41
|
+
jsdoc && 'plugin:jsdoc/recommended',
|
|
38
42
|
prettier && 'plugin:prettier/recommended',
|
|
39
43
|
].filter(Boolean);
|
|
40
44
|
|
|
@@ -71,7 +75,7 @@ export const createConfig = (options = {}) => {
|
|
|
71
75
|
'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }],
|
|
72
76
|
// ---- Common Rules ----
|
|
73
77
|
// Apply shared rules
|
|
74
|
-
...commonRules({ prettier, importOrder }),
|
|
78
|
+
...commonRules({ prettier, importOrder, jsdoc }),
|
|
75
79
|
},
|
|
76
80
|
},
|
|
77
81
|
]);
|
package/src/eslint/typescript.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Eslint Configuration (Flat)
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Project-wide ESLint configuration for TypeScript.
|
|
6
6
|
* Enforces code quality and consistent styling.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
|
|
8
|
+
* Usage: npx eslint .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { defineConfig } from 'eslint/config';
|
|
@@ -17,19 +17,23 @@ const { compat } = setup();
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates an ESLint configuration object for TypeScript projects.
|
|
20
|
-
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {boolean} [options.
|
|
23
|
-
* @
|
|
20
|
+
*
|
|
21
|
+
* @param {object} [options] - Configuration options.
|
|
22
|
+
* @param {boolean} [options.prettier] - Enable Prettier integration.
|
|
23
|
+
* @param {boolean} [options.importOrder] - Enable import order rules.
|
|
24
|
+
* @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
|
|
25
|
+
*
|
|
26
|
+
* @returns {import('eslint').Linter.Config[]} ESLint configuration array.
|
|
24
27
|
*/
|
|
25
28
|
export const createConfig = (options = {}) => {
|
|
26
|
-
const { prettier = true, importOrder = true } = options;
|
|
29
|
+
const { prettier = true, importOrder = true, jsdoc = true } = options;
|
|
27
30
|
|
|
28
31
|
// ---- Extends Configs ----
|
|
29
32
|
// Build the extends array based on enabled features
|
|
30
33
|
const extendsConfigs = [
|
|
31
34
|
'plugin:@typescript-eslint/recommended',
|
|
32
35
|
importOrder && 'plugin:import/recommended',
|
|
36
|
+
jsdoc && 'plugin:jsdoc/recommended',
|
|
33
37
|
prettier && 'plugin:prettier/recommended',
|
|
34
38
|
].filter(Boolean);
|
|
35
39
|
|
|
@@ -58,7 +62,7 @@ export const createConfig = (options = {}) => {
|
|
|
58
62
|
settings: { ...(importOrder && { 'import/resolver': { typescript: {} } }) },
|
|
59
63
|
|
|
60
64
|
// ---- Rules ----
|
|
61
|
-
rules: commonRules({ prettier, importOrder }),
|
|
65
|
+
rules: commonRules({ prettier, importOrder, jsdoc }),
|
|
62
66
|
},
|
|
63
67
|
]);
|
|
64
68
|
};
|
package/src/index.js
CHANGED
|
@@ -1,57 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Dev Configurations Index
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Central index file that re-exports all configuration presets
|
|
6
6
|
* for easy consumption by root-level config files.
|
|
7
7
|
* Docs: https://github.com/vijay/repositories/projects/dev-config
|
|
8
|
-
*
|
|
8
|
+
* =====================================================================.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* ESLint configuration for JavaScript files.
|
|
13
|
+
*
|
|
13
14
|
* @type {import('eslint').Linter.Config}
|
|
14
15
|
*/
|
|
15
16
|
export { default as eslint, createConfig as createEslintConfig } from './eslint/index.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* ESLint configuration for TypeScript files.
|
|
20
|
+
*
|
|
19
21
|
* @type {import('eslint').Linter.Config}
|
|
20
22
|
*/
|
|
21
23
|
export { default as eslintTs, createConfig as createEslintTsConfig } from './eslint/typescript.js';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* ESLint configuration for React files.
|
|
27
|
+
*
|
|
25
28
|
* @type {import('eslint').Linter.Config}
|
|
26
29
|
*/
|
|
27
30
|
export { default as eslintReact, createConfig as createEslintReactConfig } from './eslint/react.js';
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* ESLint configuration for Next.js files.
|
|
34
|
+
*
|
|
31
35
|
* @type {import('eslint').Linter.Config}
|
|
32
36
|
*/
|
|
33
37
|
export { default as eslintNext, createConfig as createEslintNextConfig } from './eslint/next.js';
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
40
|
* Prettier configuration.
|
|
41
|
+
*
|
|
37
42
|
* @type {import('prettier').Config}
|
|
38
43
|
*/
|
|
39
44
|
export { default as prettier } from './prettier/index.js';
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
47
|
* Commitlint configuration.
|
|
48
|
+
*
|
|
43
49
|
* @type {import('@commitlint/types').UserConfig}
|
|
44
50
|
*/
|
|
45
51
|
export { default as commitlint } from './commitlint/index.js';
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* Next.js sitemap configuration.
|
|
55
|
+
*
|
|
49
56
|
* @type {import('next-sitemap').IConfig}
|
|
50
57
|
*/
|
|
51
58
|
export { default as nextSitemap, createSitemapConfig } from './next-sitemap/index.js';
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
61
|
* Stylelint configuration.
|
|
62
|
+
*
|
|
55
63
|
* @type {import('stylelint').Config}
|
|
56
64
|
*/
|
|
57
65
|
export { default as stylelint } from './stylelint/index.js';
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Next Sitemap Configuration
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Next.js sitemap configuration for generating SEO-friendly
|
|
6
6
|
* sitemaps with robots.txt support.
|
|
7
|
-
* Docs:
|
|
8
|
-
*
|
|
7
|
+
* Docs: https://github.com/iamvishnusankar/next-sitemap
|
|
8
|
+
* =====================================================================.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates a sitemap configuration object for next-sitemap.
|
|
13
|
-
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {string} [options.
|
|
16
|
-
* @param {string
|
|
17
|
-
* @
|
|
13
|
+
*
|
|
14
|
+
* @param {object} [options] - Configuration options.
|
|
15
|
+
* @param {string} [options.siteUrl] - Site base URL.
|
|
16
|
+
* @param {string} [options.outDir] - Output directory for sitemap files.
|
|
17
|
+
* @param {string[]} [options.exclude] - Paths to exclude from sitemap.
|
|
18
|
+
*
|
|
19
|
+
* @returns {import('next-sitemap').IConfig} Sitemap configuration object.
|
|
18
20
|
*/
|
|
19
21
|
export function createSitemapConfig(options = {}) {
|
|
20
22
|
const { siteUrl = 'https://example.com', outDir = './public', exclude = ['/404', '/500'] } = options;
|
package/src/prettier/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Prettier Configuration
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: Code formatting configuration for consistent style across
|
|
6
6
|
* the project.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://prettier.io/docs/en/configuration.html
|
|
8
|
+
* Usage: npx prettier --write .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/** @type {import("prettier").Config} */
|
package/src/stylelint/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* =====================================================================.
|
|
3
3
|
* Stylelint Configuration
|
|
4
|
-
*
|
|
4
|
+
* =====================================================================.
|
|
5
5
|
* Purpose: CSS/SCSS linting configuration for consistent styling and
|
|
6
6
|
* proper property ordering.
|
|
7
|
-
* Docs:
|
|
8
|
-
* Usage:
|
|
9
|
-
*
|
|
7
|
+
* Docs: https://stylelint.io/user-guide/configure
|
|
8
|
+
* Usage: npx stylelint .
|
|
9
|
+
* =====================================================================.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/** @type {import("stylelint").Config} */
|