@vijayhardaha/dev-config 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Vijay Hardaha
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 ADDED
@@ -0,0 +1,86 @@
1
+ # @vijayhardaha/dev-config
2
+
3
+ Reusable development configuration package for Next.js + TypeScript projects.
4
+
5
+ ## Features
6
+
7
+ - **ESLint** - Modular flat config with support for JavaScript, TypeScript, React, and Next.js
8
+ - **Prettier** - Consistent code formatting with language-specific rules
9
+ - **Commitlint** - Enforces conventional commit messages
10
+ - **TypeScript** - Base configuration for type checking
11
+ - **JSConfig** - IntelliSense support for JavaScript projects
12
+ - **Stylelint** - CSS/SCSS linting configuration
13
+ - **Next Sitemap** - Sitemap generation configuration
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @vijayhardaha/dev-config --save-dev
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### ESLint
24
+
25
+ Create `eslint.config.mjs` in your project root:
26
+
27
+ ```javascript
28
+ import { createConfig } from "@vijayhardaha/dev-config/eslint/next";
29
+
30
+ export default createConfig();
31
+ ```
32
+
33
+ ### Prettier
34
+
35
+ Create `prettier.config.mjs` in your project root:
36
+
37
+ ```javascript
38
+ import prettierConfig from "@vijayhardaha/dev-config/prettier";
39
+
40
+ export default prettierConfig;
41
+ ```
42
+
43
+ ### Commitlint
44
+
45
+ Create `commitlint.config.mjs` in your project root:
46
+
47
+ ```javascript
48
+ import commitlintConfig from "@vijayhardaha/dev-config/commitlint";
49
+
50
+ export default commitlintConfig;
51
+ ```
52
+
53
+ ## Configuration Options
54
+
55
+ ### ESLint
56
+
57
+ ```javascript
58
+ import { createConfig } from "@vijayhardaha/dev-config/eslint/next";
59
+
60
+ export default createConfig({
61
+ prettier: true, // Enable Prettier integration
62
+ importOrder: true, // Enable import ordering
63
+ react: true, // Enable React rules
64
+ a11y: true // Enable accessibility rules
65
+ });
66
+ ```
67
+
68
+ Available configs:
69
+
70
+ - `@vijayhardaha/dev-config/eslint` - JavaScript
71
+ - `@vijayhardaha/dev-config/eslint/ts` - TypeScript
72
+ - `@vijayhardaha/dev-config/eslint/react` - React + TypeScript
73
+ - `@vijayhardaha/dev-config/eslint/next` - Next.js + React + TypeScript
74
+
75
+ ## Scripts
76
+
77
+ | Command | Description |
78
+ | ---------------------- | ---------------------- |
79
+ | `npm run lint` | Run ESLint |
80
+ | `npm run lint:fix` | Auto-fix ESLint issues |
81
+ | `npm run format` | Format with Prettier |
82
+ | `npm run format:check` | Check formatting |
83
+
84
+ ## License
85
+
86
+ MIT
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@vijayhardaha/dev-config",
3
+ "version": "1.0.0",
4
+ "description": "Reusable development configurations for Next.js + TypeScript projects",
5
+ "author": "Vijay Hardaha",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./src/index.js",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/vijayhardaha/dev-config.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/vijayhardaha/dev-config/issues"
15
+ },
16
+ "homepage": "https://github.com/vijayhardaha/dev-config#readme",
17
+ "exports": {
18
+ ".": "./src/index.js",
19
+ "./eslint": "./src/eslint/index.js",
20
+ "./eslint/ts": "./src/eslint/ts.js",
21
+ "./eslint/react": "./src/eslint/react.js",
22
+ "./eslint/next": "./src/eslint/next.js",
23
+ "./prettier": "./src/prettier/index.js",
24
+ "./commitlint": "./src/commitlint/index.js",
25
+ "./stylelint": "./src/stylelint/index.js",
26
+ "./next-sitemap": "./src/next-sitemap/index.js",
27
+ "./typescript/base": "./src/typescript/base.json",
28
+ "./typescript/tsconfig": "./src/typescript/tsconfig.json",
29
+ "./jsconfig": "./src/jsconfig/index.json"
30
+ },
31
+ "files": [
32
+ "src",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "lint": "eslint .",
37
+ "lint:fix": "eslint . --fix",
38
+ "format": "prettier --write .",
39
+ "format:check": "prettier --check .",
40
+ "release": "release-it",
41
+ "release:dry": "release-it --dry-run",
42
+ "prepare": "husky"
43
+ },
44
+ "keywords": [
45
+ "config",
46
+ "devtools",
47
+ "eslint",
48
+ "prettier",
49
+ "commitlint",
50
+ "stylelint",
51
+ "next-sitemap",
52
+ "typescript"
53
+ ],
54
+ "peerDependencies": {
55
+ "@commitlint/cli": "^20",
56
+ "@commitlint/config-conventional": "^20",
57
+ "@eslint/compat": "^2",
58
+ "@eslint/eslintrc": "^3",
59
+ "@eslint/js": "^9",
60
+ "@next/eslint-plugin-next": "^15",
61
+ "@typescript-eslint/eslint-plugin": "^8",
62
+ "@typescript-eslint/parser": "^8",
63
+ "eslint": "^9",
64
+ "eslint-config-next": "^15",
65
+ "eslint-config-prettier": "^10",
66
+ "eslint-plugin-import": "^2",
67
+ "eslint-plugin-jsx-a11y": "^6",
68
+ "eslint-plugin-prettier": "^5",
69
+ "eslint-plugin-react": "^7",
70
+ "eslint-plugin-react-hooks": "^7",
71
+ "globals": "^17",
72
+ "prettier": "^3",
73
+ "stylelint": "^17",
74
+ "stylelint-config-property-sort-order-smacss": "^11",
75
+ "stylelint-config-standard-scss": "^17",
76
+ "stylelint-order": "^8",
77
+ "typescript": "^5"
78
+ },
79
+ "devDependencies": {
80
+ "@commitlint/cli": "^20.5.0",
81
+ "@commitlint/config-conventional": "^20.5.0",
82
+ "@eslint/compat": "^2.0.3",
83
+ "@eslint/eslintrc": "^3.3.5",
84
+ "@eslint/js": "^9.39.4",
85
+ "eslint": "^9.39.4",
86
+ "eslint-config-prettier": "^10.1.8",
87
+ "eslint-plugin-prettier": "^5.5.5",
88
+ "globals": "^17.4.0",
89
+ "husky": "^9.1.7",
90
+ "prettier": "^3.8.1",
91
+ "release-it": "^19.2.4"
92
+ }
93
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * =====================================================================
3
+ * Commitlint Configuration
4
+ * =====================================================================
5
+ * Purpose: Enforce conventional commit message standards for consistent
6
+ * and meaningful Git commit history.
7
+ * Docs: https://commitlint.js.org/#/
8
+ * =====================================================================
9
+ */
10
+
11
+ /** @type {import('@commitlint/types').UserConfig} */
12
+ const config = {
13
+ // ---- Extends ----
14
+ // Use conventional commit rules as the base configuration
15
+ extends: ['@commitlint/config-conventional'],
16
+
17
+ // ---- Rules ----
18
+ // Maximum length for the commit header (first line)
19
+ 'header-max-length': [2, 'always', 50],
20
+
21
+ // Maximum length for any line in the commit body
22
+ 'body-max-line-length': [2, 'always', 72],
23
+
24
+ // Commit body must be in sentence case or lower case
25
+ 'body-case': [2, 'always', ['sentence-case', 'lower-case']],
26
+
27
+ // Subject case is not enforced (allows flexibility)
28
+ 'subject-case': [0],
29
+ };
30
+
31
+ export default config;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * =====================================================================
3
+ * Eslint Common Configuration
4
+ * =====================================================================
5
+ * Purpose: Shared setup for all ESLint configurations including common
6
+ * ignores, parser setup, and rule definitions.
7
+ * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
+ * =====================================================================
9
+ */
10
+
11
+ import path from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ import { FlatCompat } from '@eslint/eslintrc';
15
+ import js from '@eslint/js';
16
+ import tsParser from '@typescript-eslint/parser';
17
+ import { globalIgnores } from 'eslint/config';
18
+ import globals from 'globals';
19
+
20
+ /**
21
+ * Global ignore patterns for ESLint to skip build artifacts, dependencies,
22
+ * and generated files during linting.
23
+ */
24
+ export const ignores = [
25
+ '**/.git/',
26
+ '**/.idea/',
27
+ '**/.vscode/',
28
+ '**/.husky/',
29
+ '**/node_modules/',
30
+ '**/.next/',
31
+ '**/dist/',
32
+ '**/build/',
33
+ '**/out/',
34
+ '**/.vercel/',
35
+ '**/.cache/',
36
+ '**/.turbo/',
37
+ '**/*.tsbuildinfo',
38
+ '**/coverage/',
39
+ '**/test-results/',
40
+ '**/.playwright-report/',
41
+ '**/public/',
42
+ '**/.env*',
43
+ '**/next-env.d.ts',
44
+ '**/*.log',
45
+ '**/.DS_Store',
46
+ '**/Thumbs.db',
47
+ '**/*.tmp',
48
+ ];
49
+
50
+ const __filename = fileURLToPath(import.meta.url);
51
+ const __dirname = path.dirname(__filename);
52
+
53
+ /**
54
+ * Creates a FlatCompat instance for using flat config format with older
55
+ * ESLint configurations.
56
+ */
57
+ const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.configs.recommended });
58
+
59
+ /**
60
+ * Returns the setup object containing shared utilities for ESLint configs.
61
+ * @returns {{ compat: FlatCompat, tsParser: typeof tsParser, __dirname: string }}
62
+ */
63
+ export const setup = () => ({ compat, tsParser, __dirname });
64
+
65
+ /**
66
+ * Global ignores configuration using ESLint's globalIgnores helper.
67
+ * @type {import('eslint').Linter.Config}
68
+ */
69
+ export const commonIgnores = [globalIgnores(ignores)];
70
+
71
+ /**
72
+ * Common parser configuration for TypeScript files.
73
+ * @type {{ parser: typeof tsParser }}
74
+ */
75
+ export const commonParser = { parser: tsParser };
76
+
77
+ /**
78
+ * Common language options for ESLint including ECMAScript version,
79
+ * source type, and global variables.
80
+ * @type {import('eslint').Linter.LanguageOptions}
81
+ */
82
+ export const commonLanguageOptions = {
83
+ ecmaVersion: 'latest',
84
+ sourceType: 'module',
85
+ globals: { ...globals.browser, ...globals.node },
86
+ };
87
+
88
+ /**
89
+ * Creates a rules object based on the provided options.
90
+ * @param {Object} [options] - Configuration options
91
+ * @param {boolean} [options.typescript=true] - Enable TypeScript-specific rules
92
+ * @param {boolean} [options.importOrder=true] - Enable import order rules
93
+ * @param {boolean} [options.prettier=true] - Enable Prettier integration
94
+ * @returns {Object} ESLint rules object
95
+ */
96
+ export const commonRules = (options = {}) => {
97
+ const { typescript = true, importOrder = true, prettier = true } = options;
98
+
99
+ return {
100
+ // ---- TypeScript Rules ----
101
+ // Report unused variables with TypeScript-aware analysis
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
+ }),
115
+
116
+ // ---- Import Order Rules ----
117
+ // Enforce consistent import ordering with specific group priorities
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
+ }),
134
+
135
+ // ---- Prettier Integration ----
136
+ // Report Prettier formatting issues as warnings
137
+ ...(prettier && { 'prettier/prettier': 'warn' }),
138
+ };
139
+ };
140
+
141
+ /**
142
+ * File patterns for ESLint configuration.
143
+ * @type {{ withTs: string[], withoutTs: string[] }}
144
+ */
145
+ export const files = { withTs: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'], withoutTs: ['**/*.{js,jsx,mjs,cjs}'] };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * =====================================================================
3
+ * Eslint Configuration (Flat)
4
+ * =====================================================================
5
+ * Purpose: Project-wide ESLint configuration for JavaScript.
6
+ * Enforces code quality and consistent styling.
7
+ * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
+ * Usage: npx eslint .
9
+ * =====================================================================
10
+ */
11
+
12
+ import { defineConfig } from 'eslint/config';
13
+
14
+ import { setup, commonIgnores, commonRules, commonLanguageOptions, files } from './common.js';
15
+
16
+ const { compat } = setup();
17
+
18
+ /**
19
+ * Creates an ESLint configuration object with optional features.
20
+ * @param {Object} [options] - Configuration options
21
+ * @param {boolean} [options.prettier=true] - Enable Prettier integration
22
+ * @param {boolean} [options.importOrder=true] - Enable import order rules
23
+ * @returns {import('eslint').Linter.Config[]} ESLint configuration array
24
+ */
25
+ export const createConfig = (options = {}) => {
26
+ const { prettier = true, importOrder = true } = options;
27
+
28
+ // ---- Extends Configs ----
29
+ // Build the extends array based on enabled features
30
+ const extendsConfigs = [importOrder && 'plugin:import/recommended', prettier && 'plugin:prettier/recommended'].filter(
31
+ Boolean
32
+ );
33
+
34
+ return defineConfig([
35
+ // ---- Global Ignores ----
36
+ ...commonIgnores,
37
+
38
+ // ---- Extends Configs ----
39
+ ...compat.extends(...extendsConfigs),
40
+
41
+ {
42
+ // ---- JavaScript Files Configuration ----
43
+ // Apply to JavaScript files without TypeScript
44
+ files: files.withoutTs,
45
+
46
+ languageOptions: commonLanguageOptions,
47
+
48
+ rules: {
49
+ // ---- Unused Variables Rule ----
50
+ // Report unused variables for JavaScript files
51
+ 'no-unused-vars': [
52
+ 'error',
53
+ {
54
+ vars: 'all',
55
+ args: 'after-used',
56
+ varsIgnorePattern: '^_',
57
+ argsIgnorePattern: '^_',
58
+ ignoreRestSiblings: true,
59
+ caughtErrors: 'all',
60
+ },
61
+ ],
62
+ // ---- Common Rules ----
63
+ // Apply shared rules based on options
64
+ ...commonRules({ prettier, importOrder, typescript: false }),
65
+ },
66
+ },
67
+ ]);
68
+ };
69
+
70
+ export default createConfig();
@@ -0,0 +1,81 @@
1
+ /**
2
+ * =====================================================================
3
+ * Eslint Configuration (Flat)
4
+ * =====================================================================
5
+ * Purpose: Project-wide ESLint configuration for Next.js, TypeScript, and
6
+ * React. Enforces code quality, accessibility, and consistent styling.
7
+ * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
+ * Usage: npx eslint .
9
+ * =====================================================================
10
+ */
11
+
12
+ import { defineConfig } from 'eslint/config';
13
+
14
+ import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
15
+
16
+ const { compat, __dirname } = setup();
17
+
18
+ /**
19
+ * Creates an ESLint configuration object for Next.js projects with TypeScript
20
+ * and React support.
21
+ * @param {Object} [options] - Configuration options
22
+ * @param {boolean} [options.prettier=true] - Enable Prettier integration
23
+ * @param {boolean} [options.react=true] - Enable React-specific rules
24
+ * @param {boolean} [options.a11y=true] - Enable accessibility rules
25
+ * @param {boolean} [options.importOrder=true] - Enable import order rules
26
+ * @returns {import('eslint').Linter.Config[]} ESLint configuration array
27
+ */
28
+ export const createConfig = (options = {}) => {
29
+ const { prettier = true, react = true, a11y = true, importOrder = true } = options;
30
+
31
+ // ---- Extends Configs ----
32
+ // Build the extends array based on enabled features
33
+ const extendsConfigs = [
34
+ 'plugin:import/recommended',
35
+ 'next/core-web-vitals',
36
+ 'next/typescript',
37
+ react && 'plugin:react/recommended',
38
+ react && 'plugin:react-hooks/recommended',
39
+ a11y && 'plugin:jsx-a11y/recommended',
40
+ 'plugin:@typescript-eslint/recommended',
41
+ prettier && 'plugin:prettier/recommended',
42
+ ].filter(Boolean);
43
+
44
+ return defineConfig([
45
+ // ---- Global Ignores ----
46
+ ...commonIgnores,
47
+
48
+ // ---- Extends Configs ----
49
+ ...compat.extends(...extendsConfigs),
50
+
51
+ {
52
+ // ---- TypeScript Files Configuration ----
53
+ // Apply to TypeScript files
54
+ files: files.withTs,
55
+
56
+ languageOptions: {
57
+ ...commonLanguageOptions,
58
+ ...commonParser,
59
+ // ---- Parser Options ----
60
+ // Configure TypeScript parser with React JSX support
61
+ parserOptions: { ecmaFeatures: { jsx: true }, tsconfigRootDir: __dirname },
62
+ },
63
+
64
+ // ---- React Settings ----
65
+ ...(react && { settings: { react: { version: 'detect' } } }),
66
+
67
+ rules: {
68
+ // ---- React Rules ----
69
+ // Disable React import requirement (Next.js handles this)
70
+ ...(react && { 'react/react-in-jsx-scope': 'off' }),
71
+ // Allow JSX and global attributes
72
+ ...(react && { 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }] }),
73
+ // ---- Common Rules ----
74
+ // Apply shared rules
75
+ ...commonRules({ prettier, importOrder }),
76
+ },
77
+ },
78
+ ]);
79
+ };
80
+
81
+ export default createConfig();
@@ -0,0 +1,78 @@
1
+ /**
2
+ * =====================================================================
3
+ * Eslint Configuration (Flat)
4
+ * =====================================================================
5
+ * Purpose: Project-wide ESLint configuration for React with TypeScript.
6
+ * Enforces code quality, accessibility, and consistent styling.
7
+ * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
+ * Usage: npx eslint .
9
+ * =====================================================================
10
+ */
11
+
12
+ import { defineConfig } from 'eslint/config';
13
+
14
+ import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
15
+
16
+ const { compat, __dirname } = setup();
17
+
18
+ /**
19
+ * Creates an ESLint configuration object for React projects with TypeScript
20
+ * support.
21
+ * @param {Object} [options] - Configuration options
22
+ * @param {boolean} [options.prettier=true] - Enable Prettier integration
23
+ * @param {boolean} [options.a11y=true] - Enable accessibility rules
24
+ * @param {boolean} [options.importOrder=true] - Enable import order rules
25
+ * @returns {import('eslint').Linter.Config[]} ESLint configuration array
26
+ */
27
+ export const createConfig = (options = {}) => {
28
+ const { prettier = true, a11y = true, importOrder = true } = options;
29
+
30
+ // ---- Extends Configs ----
31
+ // Build the extends array based on enabled features
32
+ const extendsConfigs = [
33
+ 'plugin:import/recommended',
34
+ 'plugin:react/recommended',
35
+ 'plugin:react-hooks/recommended',
36
+ a11y && 'plugin:jsx-a11y/recommended',
37
+ 'plugin:@typescript-eslint/recommended',
38
+ prettier && 'plugin:prettier/recommended',
39
+ ].filter(Boolean);
40
+
41
+ return defineConfig([
42
+ // ---- Global Ignores ----
43
+ ...commonIgnores,
44
+
45
+ // ---- Extends Configs ----
46
+ ...compat.extends(...extendsConfigs),
47
+
48
+ {
49
+ // ---- TypeScript Files Configuration ----
50
+ // Apply to TypeScript files
51
+ files: files.withTs,
52
+
53
+ languageOptions: {
54
+ ...commonLanguageOptions,
55
+ ...commonParser,
56
+ // ---- Parser Options ----
57
+ // Configure TypeScript parser with React JSX support
58
+ parserOptions: { ecmaFeatures: { jsx: true }, tsconfigRootDir: __dirname },
59
+ },
60
+
61
+ // ---- React Settings ----
62
+ settings: { react: { version: 'detect' } },
63
+
64
+ rules: {
65
+ // ---- React Rules ----
66
+ // Disable React import requirement (Next.js handles this)
67
+ 'react/react-in-jsx-scope': 'off',
68
+ // Allow JSX and global attributes
69
+ 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }],
70
+ // ---- Common Rules ----
71
+ // Apply shared rules
72
+ ...commonRules({ prettier, importOrder }),
73
+ },
74
+ },
75
+ ]);
76
+ };
77
+
78
+ export default createConfig();
@@ -0,0 +1,61 @@
1
+ /**
2
+ * =====================================================================
3
+ * Eslint Configuration (Flat)
4
+ * =====================================================================
5
+ * Purpose: Project-wide ESLint configuration for TypeScript.
6
+ * Enforces code quality and consistent styling.
7
+ * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
+ * Usage: npx eslint .
9
+ * =====================================================================
10
+ */
11
+
12
+ import { defineConfig } from 'eslint/config';
13
+
14
+ import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
15
+
16
+ const { compat, __dirname } = setup();
17
+
18
+ /**
19
+ * Creates an ESLint configuration object for TypeScript projects.
20
+ * @param {Object} [options] - Configuration options
21
+ * @param {boolean} [options.prettier=true] - Enable Prettier integration
22
+ * @param {boolean} [options.importOrder=true] - Enable import order rules
23
+ * @returns {import('eslint').Linter.Config[]} ESLint configuration array
24
+ */
25
+ export const createConfig = (options = {}) => {
26
+ const { prettier = true, importOrder = true } = options;
27
+
28
+ // ---- Extends Configs ----
29
+ // Build the extends array based on enabled features
30
+ const extendsConfigs = [
31
+ 'plugin:@typescript-eslint/recommended',
32
+ importOrder && 'plugin:import/recommended',
33
+ prettier && 'plugin:prettier/recommended',
34
+ ].filter(Boolean);
35
+
36
+ return defineConfig([
37
+ // ---- Global Ignores ----
38
+ ...commonIgnores,
39
+
40
+ // ---- Extends Configs ----
41
+ ...compat.extends(...extendsConfigs),
42
+
43
+ {
44
+ // ---- TypeScript Files Configuration ----
45
+ // Apply to TypeScript files
46
+ files: files.withTs,
47
+
48
+ languageOptions: {
49
+ ...commonLanguageOptions,
50
+ ...commonParser,
51
+ // ---- Parser Options ----
52
+ // Configure TypeScript parser
53
+ parserOptions: { tsconfigRootDir: __dirname },
54
+ },
55
+
56
+ rules: commonRules({ prettier, importOrder }),
57
+ },
58
+ ]);
59
+ };
60
+
61
+ export default createConfig();
package/src/index.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * =====================================================================
3
+ * Dev Configurations Index
4
+ * =====================================================================
5
+ * Purpose: Central index file that re-exports all configuration presets
6
+ * for easy consumption by root-level config files.
7
+ * Docs: https://github.com/vijay/repositories/projects/dev-config
8
+ * =====================================================================
9
+ */
10
+
11
+ /**
12
+ * ESLint configuration for JavaScript files.
13
+ * @type {import('eslint').Linter.Config}
14
+ */
15
+ export { default as eslint, createConfig as createEslintConfig } from './eslint/index.js';
16
+
17
+ /**
18
+ * ESLint configuration for TypeScript files.
19
+ * @type {import('eslint').Linter.Config}
20
+ */
21
+ export { default as eslintTs, createConfig as createEslintTsConfig } from './eslint/typescript.js';
22
+
23
+ /**
24
+ * ESLint configuration for React files.
25
+ * @type {import('eslint').Linter.Config}
26
+ */
27
+ export { default as eslintReact, createConfig as createEslintReactConfig } from './eslint/react.js';
28
+
29
+ /**
30
+ * ESLint configuration for Next.js files.
31
+ * @type {import('eslint').Linter.Config}
32
+ */
33
+ export { default as eslintNext, createConfig as createEslintNextConfig } from './eslint/next.js';
34
+
35
+ /**
36
+ * Prettier configuration.
37
+ * @type {import('prettier').Config}
38
+ */
39
+ export { default as prettier } from './prettier/index.js';
40
+
41
+ /**
42
+ * Commitlint configuration.
43
+ * @type {import('@commitlint/types').UserConfig}
44
+ */
45
+ export { default as commitlint } from './commitlint/index.js';
46
+
47
+ /**
48
+ * Next.js sitemap configuration.
49
+ * @type {import('next-sitemap').IConfig}
50
+ */
51
+ export { default as nextSitemap, createSitemapConfig } from './next-sitemap/index.js';
52
+
53
+ /**
54
+ * Stylelint configuration.
55
+ * @type {import('stylelint').Config}
56
+ */
57
+ export { default as stylelint } from './stylelint/index.js';
58
+
59
+ /**
60
+ * TypeScript base configuration.
61
+ * @type {import('typescript').CompilerOptions}
62
+ */
63
+ export { default as typescriptBase } from './typescript/base.json';
@@ -0,0 +1,24 @@
1
+ // =====================================================================
2
+ // JavaScript Configuration
3
+ // =====================================================================
4
+ // Purpose: JavaScript configuration for module resolution and path mapping.
5
+ // Docs: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler#jsconfigjson
6
+ // =====================================================================
7
+
8
+ {
9
+ // ---- Compiler Options ----
10
+ // Use React's modern JSX transform for better performance
11
+ "compilerOptions": {
12
+ "jsx": "react-jsx",
13
+ // Allow importing JSON modules
14
+ "resolveJsonModule": true,
15
+ // Base directory for non-relative imports
16
+ "baseUrl": ".",
17
+ // Map @/* to ./src/* for cleaner imports
18
+ "paths": { "@/*": ["./src/*"] }
19
+ },
20
+
21
+ // ---- Excluded Files ----
22
+ // Skip directories that don't need type checking
23
+ "exclude": ["node_modules", ".next", "out"]
24
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * =====================================================================
3
+ * Next Sitemap Configuration
4
+ * =====================================================================
5
+ * Purpose: Next.js sitemap configuration for generating SEO-friendly
6
+ * sitemaps with robots.txt support.
7
+ * Docs: https://github.com/iamvishnusankar/next-sitemap
8
+ * =====================================================================
9
+ */
10
+
11
+ /**
12
+ * Creates a sitemap configuration object for next-sitemap.
13
+ * @param {Object} [options] - Configuration options
14
+ * @param {string} [options.siteUrl='https://example.com'] - Site base URL
15
+ * @param {string} [options.outDir='./public'] - Output directory for sitemap files
16
+ * @param {string[]} [options.exclude=['/404', '/500']] - Paths to exclude from sitemap
17
+ * @returns {import('next-sitemap').IConfig} Sitemap configuration object
18
+ */
19
+ export function createSitemapConfig(options = {}) {
20
+ const { siteUrl = 'https://example.com', outDir = './public', exclude = ['/404', '/500'] } = options;
21
+
22
+ // ---- Last Modified ----
23
+ // Use current timestamp for all sitemap entries
24
+ const lastModified = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
25
+
26
+ return {
27
+ // ---- Basic Settings ----
28
+ siteUrl,
29
+ sitemapBaseFileName: 'sitemap',
30
+ trailingSlash: false,
31
+
32
+ // ---- Output Settings ----
33
+ outDir,
34
+ changefreq: 'weekly',
35
+ priority: 0.7,
36
+ exclude,
37
+
38
+ // ---- Transform Function ----
39
+ // Add last modified timestamp to each entry
40
+ transform: (_config, path) => {
41
+ return { loc: path, changefreq: _config.changefreq, priority: _config.priority, lastmod: lastModified };
42
+ },
43
+
44
+ // ---- Robots.txt Generation ----
45
+ generateRobotsTxt: true,
46
+ robotsTxtOptions: {
47
+ policies: [{ userAgent: '*', allow: '/' }],
48
+ // ---- Custom Robots.txt Transform ----
49
+ // Remove the default Host header from generated robots.txt
50
+ transformRobotsTxt: async (_config, robotsTxt) => {
51
+ const hostHeader = `# Host\nHost: ${siteUrl}\n\n`;
52
+ return robotsTxt.replace(hostHeader, '');
53
+ },
54
+ },
55
+ };
56
+ }
57
+
58
+ export default createSitemapConfig();
@@ -0,0 +1,66 @@
1
+ /**
2
+ * =====================================================================
3
+ * Prettier Configuration
4
+ * =====================================================================
5
+ * Purpose: Code formatting configuration for consistent style across
6
+ * the project.
7
+ * Docs: https://prettier.io/docs/en/configuration.html
8
+ * Usage: npx prettier --write .
9
+ * =====================================================================
10
+ */
11
+
12
+ /** @type {import("prettier").Config} */
13
+ const config = {
14
+ // ---- Basic Settings ----
15
+ // Maximum line width before wrapping
16
+ printWidth: 120,
17
+ // Number of spaces per indentation
18
+ tabWidth: 2,
19
+ // Use spaces instead of tabs
20
+ useTabs: false,
21
+ // Add semicolons at the end of statements
22
+ semi: true,
23
+ // Use single quotes for strings
24
+ singleQuote: false,
25
+ // Handle line endings automatically
26
+ endOfLine: 'auto',
27
+ // Always include parentheses around arrow function parameters
28
+ arrowParens: 'always',
29
+ // Trailing commas in multi-line structures
30
+ trailingComma: 'es5',
31
+ // Add spaces between object braces
32
+ bracketSpacing: true,
33
+ // Do not put single-line objects on a single line
34
+ bracketSameLine: false,
35
+ // Preserve prose wrapping in Markdown files
36
+ proseWrap: 'preserve',
37
+ // Experimental operator position at start
38
+ experimentalOperatorPosition: 'start',
39
+ // Collapse object literals
40
+ objectWrap: 'collapse',
41
+
42
+ // ---- Overrides ----
43
+ // Different formatting rules for different file types
44
+ overrides: [
45
+ // ---- Backend Languages ----
46
+ // Use 4-space indentation for Python and PHP
47
+ { files: ['*.py', '*.php'], options: { tabWidth: 4, useTabs: false } },
48
+
49
+ // ---- JavaScript/TypeScript ----
50
+ // Use 2-space indentation and single quotes for JS/TS
51
+ { files: ['*.js', '*.ts', '*.mjs', '*.cjs', '*.jsx', '*.tsx'], options: { tabWidth: 2, singleQuote: true } },
52
+
53
+ // ---- Stylesheet Languages ----
54
+ // Use 2-space indentation for CSS/SCSS/SASS
55
+ { files: ['*.css', '*.scss', '*.sass'], options: { tabWidth: 2 } },
56
+
57
+ // ---- Data & Documentation ----
58
+ // Use 2-space indentation and no trailing commas for JSON/YAML/Markdown
59
+ {
60
+ files: ['*.json', '*.jsonc', '*.yml', '*.yaml', '*.md', '*.mdx'],
61
+ options: { tabWidth: 2, trailingComma: 'none' },
62
+ },
63
+ ],
64
+ };
65
+
66
+ export default config;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * =====================================================================
3
+ * Stylelint Configuration
4
+ * =====================================================================
5
+ * Purpose: CSS/SCSS linting configuration for consistent styling and
6
+ * proper property ordering.
7
+ * Docs: https://stylelint.io/user-guide/configure
8
+ * Usage: npx stylelint .
9
+ * =====================================================================
10
+ */
11
+
12
+ /** @type {import("stylelint").Config} */
13
+ const config = {
14
+ // ---- Extends ----
15
+ // Use standard SCSS configuration and property sort order
16
+ extends: ['stylelint-config-standard-scss', 'stylelint-config-property-sort-order-smacss'],
17
+
18
+ // ---- Plugins ----
19
+ // Use stylelint-order for property sorting
20
+ plugins: ['stylelint-order'],
21
+
22
+ // ---- Rules ----
23
+ // Disable specific rules that are too strict or conflict with team style
24
+ rules: {
25
+ 'selector-class-pattern': null,
26
+ 'selector-id-pattern': null,
27
+ 'no-empty-source': null,
28
+ 'function-url-quotes': null,
29
+ 'no-descending-specificity': null,
30
+ 'comment-no-empty': null,
31
+ 'scss/comment-no-empty': null,
32
+ },
33
+ };
34
+
35
+ export default config;
@@ -0,0 +1,42 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "lib": ["ES2024", "DOM", "DOM.Iterable"],
5
+ "jsx": "react-jsx",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "paths": { "@/*": ["./src/*"] },
11
+ "resolveJsonModule": true,
12
+ "esModuleInterop": true,
13
+ "verbatimModuleSyntax": true,
14
+ "incremental": true,
15
+ "noEmit": true,
16
+ "isolatedModules": true,
17
+ "allowJs": true,
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noImplicitReturns": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "useDefineForClassFields": true,
24
+ "skipLibCheck": true,
25
+ "forceConsistentCasingInFileNames": true
26
+ },
27
+ "include": [
28
+ ".next/dev/types/**/*.ts",
29
+ ".next/types/**/*.ts",
30
+ "*.config.mjs",
31
+ "*.config.ts",
32
+ "*.d.ts",
33
+ "**/*.js",
34
+ "**/*.jsx",
35
+ "**/*.ts",
36
+ "**/*.tsx",
37
+ "**/*.mjs",
38
+ "**/*.cjs",
39
+ "next-env.d.ts"
40
+ ],
41
+ "exclude": ["node_modules"]
42
+ }