From fe87ac243013fbb1c05d9462e5f3d29b34e4a8aa Mon Sep 17 00:00:00 2001 From: raj-vc Date: Tue, 19 Dec 2023 16:03:41 +0530 Subject: [PATCH 01/14] changes: added nextjs config folder and update config --- config/{ => common}/.gitattributes | 0 config/{ => common}/.lintstagedrc.json | 0 config/{ => common}/.prettierignore | 0 config/{ => common}/.prettierrc.json | 0 config/{ => common}/extensions.json | 0 config/{ => common}/pre-commit | 0 config/{ => common}/settings.json | 0 config/{ => nextjs}/.eslintrc.json | 0 index.js | 67 +++++++++++++++++++++----- package.json | 9 +--- 10 files changed, 56 insertions(+), 20 deletions(-) rename config/{ => common}/.gitattributes (100%) rename config/{ => common}/.lintstagedrc.json (100%) rename config/{ => common}/.prettierignore (100%) rename config/{ => common}/.prettierrc.json (100%) rename config/{ => common}/extensions.json (100%) rename config/{ => common}/pre-commit (100%) rename config/{ => common}/settings.json (100%) rename config/{ => nextjs}/.eslintrc.json (100%) diff --git a/config/.gitattributes b/config/common/.gitattributes similarity index 100% rename from config/.gitattributes rename to config/common/.gitattributes diff --git a/config/.lintstagedrc.json b/config/common/.lintstagedrc.json similarity index 100% rename from config/.lintstagedrc.json rename to config/common/.lintstagedrc.json diff --git a/config/.prettierignore b/config/common/.prettierignore similarity index 100% rename from config/.prettierignore rename to config/common/.prettierignore diff --git a/config/.prettierrc.json b/config/common/.prettierrc.json similarity index 100% rename from config/.prettierrc.json rename to config/common/.prettierrc.json diff --git a/config/extensions.json b/config/common/extensions.json similarity index 100% rename from config/extensions.json rename to config/common/extensions.json diff --git a/config/pre-commit b/config/common/pre-commit similarity index 100% rename from config/pre-commit rename to config/common/pre-commit diff --git a/config/settings.json b/config/common/settings.json similarity index 100% rename from config/settings.json rename to config/common/settings.json diff --git a/config/.eslintrc.json b/config/nextjs/.eslintrc.json similarity index 100% rename from config/.eslintrc.json rename to config/nextjs/.eslintrc.json diff --git a/index.js b/index.js index b9ec212..eb7b585 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,29 @@ function help(code) { process.exit(code); } +const reactPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { + console.log("Installing required plugins..."); + execSync( + `${install} @types/node @types/react @types/react-dom eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-next eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-react-hooks husky lint-staged prettier ${devInstall} ${forceCMD}`, + { + stdio: "inherit", + } + ); +}; + +const reactEslintConfigCmd = () => { + const configPath = resolve(__dirname, `./config/nextjs/.eslintrc.json`); + copyFileSync(configPath, ".eslintrc.json"); +}; + +const packagesInstallCmds = { + nextjs: reactPackagesInstallCmd, +}; + +const eslintConfigCmds = { + nextjs: reactEslintConfigCmd, +}; + async function init() { const packageManager = await select({ message: "Select a package manager", @@ -33,6 +56,24 @@ async function init() { ], }); + const technology = await select({ + message: "Select a technology", + choices: [ + { + name: "NextJs", + value: "nextjs", + }, + { + name: "Angular", + value: "angular", + }, + { + name: "NestJs", + value: "nestjs", + }, + ], + }); + const isForceCmd = process?.argv.some((arg) => arg === "--force"); const commandsForPackageManager = { @@ -57,13 +98,9 @@ async function init() { const { install, uninstall, devInstall } = commandsForPackageManager[packageManager]; - console.log("Installing required plugins..."); - execSync( - `${install} @types/node @types/react @types/react-dom eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-next eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-react-hooks husky lint-staged prettier ${devInstall} ${forceCMD}`, - { - stdio: "inherit", - } - ); + const installRequiredPackages = packagesInstallCmds[technology]; + + installRequiredPackages({ install, uninstall, devInstall }); execSync(`npm pkg set scripts.lint="next lint --fix`, { stdio: "inherit", @@ -86,7 +123,6 @@ async function init() { }); const configNames = [ - ".eslintrc.json", ".gitattributes", ".lintstagedrc.json", ".prettierignore", @@ -94,18 +130,25 @@ async function init() { ]; console.log("Coping configuration files"); + const eslintConfigCmd = eslintConfigCmds[technology]; + + eslintConfigCmd(); + configNames.forEach((configName) => { - const configPath = resolve(__dirname, `./config/${configName}`); + const configPath = resolve(__dirname, `./config/common/${configName}`); copyFileSync(configPath, configName); }); - const preCommitConfigPath = resolve(__dirname, "./config/pre-commit"); + const preCommitConfigPath = resolve(__dirname, "./config/common/pre-commit"); copyFileSync(preCommitConfigPath, "./.husky/pre-commit"); mkdir("./.vscode", () => {}); - const vscodeConfigPath = resolve(__dirname, "./config/settings.json"); - const vscodeExtensionsPath = resolve(__dirname, "./config/extensions.json"); + const vscodeConfigPath = resolve(__dirname, "./config/common/settings.json"); + const vscodeExtensionsPath = resolve( + __dirname, + "./config/common/extensions.json" + ); copyFileSync(vscodeConfigPath, "./.vscode/settings.json"); copyFileSync(vscodeExtensionsPath, "./.vscode/extensions.json"); diff --git a/package.json b/package.json index c587c52..e91516f 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,7 @@ }, "files": [ "index.js", - "./config/.eslintrc.json", - "./config/.gitattributes", - "./config/.lintstagedrc.json", - "./config/.prettierignore", - "./config/.prettierrc.json", - "./config/pre-commit", - "./config/settings.json", - "./config/extensions.json" + "config/**" ], "repository": { "type": "git", From 32737b614ee83520a7da87f5721b3a71eb50199d Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Wed, 20 Dec 2023 05:52:38 +0000 Subject: [PATCH 02/14] add config file for nestjs --- config/common/.prettierignore | 1 + config/common/extensions.json | 2 + config/nestjs/.eslintrc.js | 82 ++++++++++++++++++++ config/nestjs/.lintstagedrc.json | 9 +++ config/nestjs/prettierrc | 8 ++ config/{common => nextjs}/.lintstagedrc.json | 0 config/{common => nextjs}/.prettierrc.json | 0 index.js | 46 +++++++++-- 8 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 config/nestjs/.eslintrc.js create mode 100644 config/nestjs/.lintstagedrc.json create mode 100644 config/nestjs/prettierrc rename config/{common => nextjs}/.lintstagedrc.json (100%) rename config/{common => nextjs}/.prettierrc.json (100%) diff --git a/config/common/.prettierignore b/config/common/.prettierignore index 7974f8b..9c403ae 100644 --- a/config/common/.prettierignore +++ b/config/common/.prettierignore @@ -1,6 +1,7 @@ .next .cache package-lock.json +dist public node_modules next-env.d.ts diff --git a/config/common/extensions.json b/config/common/extensions.json index a3695e6..fd7817d 100644 --- a/config/common/extensions.json +++ b/config/common/extensions.json @@ -9,6 +9,8 @@ "yzhang.markdown-all-in-one", "christian-kohler.path-intellisense", "esbenp.prettier-vscode", + "chakrounanas.turbo-console-log", "sonarsource.sonarlint-vscode" + ] } \ No newline at end of file diff --git a/config/nestjs/.eslintrc.js b/config/nestjs/.eslintrc.js new file mode 100644 index 0000000..c1e342b --- /dev/null +++ b/config/nestjs/.eslintrc.js @@ -0,0 +1,82 @@ +module.exports = { + parser: "@typescript-eslint/parser", + parserOptions: { + project: "tsconfig.json", + tsconfigRootDir: __dirname, + sourceType: "module", + }, + plugins: ["@typescript-eslint/eslint-plugin"], + extends: [ + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: [".eslintrc.js"], + rules: { + "@typescript-eslint/interface-name-prefix": "off", + "@typescript-eslint/explicit-function-return-type": "error", + "@typescript-eslint/explicit-module-boundary-types": "warn", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/no-invalid-this": "off", + "@typescript-eslint/no-unused-expressions": "warn", + "@typescript-eslint/return-await": "warn", + "@typescript-eslint/member-ordering": "off", + "@typescript-eslint/promise-function-async": "error", + "@typescript-eslint/prefer-optional-chain": "error", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/naming-convention": [ + "error", + { selector: "default", format: ["strictCamelCase"] }, + { + selector: "variable", + format: ["strictCamelCase", "UPPER_CASE", "PascalCase"], + }, + { + selector: "parameter", + modifiers: ["unused"], + format: ["strictCamelCase"], + leadingUnderscore: "allow", + }, + { selector: "property", format: null }, + { selector: "typeProperty", format: null }, + { selector: "typeLike", format: ["StrictPascalCase"] }, + { selector: "enumMember", format: ["UPPER_CASE"] }, + ], + "no-useless-return": "error", + "no-constant-condition": "warn", + "max-len": [ + "error", + { + code: 200, + skipBlankLines: true, + skipComments: true, + }, + ], + "max-lines": [ + "error", + { + max: 1000, + }, + ], + "no-multiple-empty-lines": [ + "error", + { + max: 2, + maxEOF: 1, + }, + ], + "no-console": "error", + "no-mixed-operators": "error", + "keyword-spacing": "error", + "multiline-ternary": ["error", "never"], + "no-undef": "error", + "no-whitespace-before-property": "error", + "nonblock-statement-body-position": "error", + }, +}; diff --git a/config/nestjs/.lintstagedrc.json b/config/nestjs/.lintstagedrc.json new file mode 100644 index 0000000..b3cfe37 --- /dev/null +++ b/config/nestjs/.lintstagedrc.json @@ -0,0 +1,9 @@ +{ + "{src,apps,libs,test}/**/*.ts": [ + "eslint --fix", + "prettier --config ./prettierrc --write" + ], + "{src,apps,libs,test}/**/*.json": [ + "prettier --config ./.prettierrc --write" + ] +} diff --git a/config/nestjs/prettierrc b/config/nestjs/prettierrc new file mode 100644 index 0000000..bb8deae --- /dev/null +++ b/config/nestjs/prettierrc @@ -0,0 +1,8 @@ +{ + "singleQuote": true, + "semi": true, + "tabWidth": 2, + "trailingComma": "all", + "printWidth": 80, + "endOfLine": "auto" +} diff --git a/config/common/.lintstagedrc.json b/config/nextjs/.lintstagedrc.json similarity index 100% rename from config/common/.lintstagedrc.json rename to config/nextjs/.lintstagedrc.json diff --git a/config/common/.prettierrc.json b/config/nextjs/.prettierrc.json similarity index 100% rename from config/common/.prettierrc.json rename to config/nextjs/.prettierrc.json diff --git a/index.js b/index.js index eb7b585..9604c68 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,6 @@ function help(code) { } const reactPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { - console.log("Installing required plugins..."); execSync( `${install} @types/node @types/react @types/react-dom eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-next eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-react-hooks husky lint-staged prettier ${devInstall} ${forceCMD}`, { @@ -24,17 +23,54 @@ const reactPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { ); }; +const nestPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { + execSync( + `${install} eslint-config-prettier eslint-plugin-prettier eslint-plugin-promise husky lint-staged prettier ${devInstall} ${forceCMD}`, + { + stdio: "inherit", + } + ); +}; + const reactEslintConfigCmd = () => { const configPath = resolve(__dirname, `./config/nextjs/.eslintrc.json`); + const configPathForPrettier = resolve( + __dirname, + `./config/nextjs/.prettierrc.json` + ); + const configPathForLintStage = resolve( + __dirname, + `./config/nestjs/.lintstagedrc.json` + ); + copyFileSync(configPath, ".eslintrc.json"); + copyFileSync(configPathForPrettier, ".prettierrc.json"); + copyFileSync(configPathForLintStage, ".lintstagedrc.json"); +}; + +const nestEslintConfigCmd = () => { + const configPathForLint = resolve(__dirname, `./config/nestjs/.eslintrc.js`); + const configPathForPrettier = resolve( + __dirname, + `./config/nestjs/.prettierrc` + ); + const configPathForLintStage = resolve( + __dirname, + `./config/nestjs/.lintstagedrc.json` + ); + copyFileSync(configPathForLint, ".eslintrc.js"); + copyFileSync(configPathForPrettier, ".prettierrc"); + copyFileSync(configPathForLintStage, ".lintstagedrc.json"); }; const packagesInstallCmds = { nextjs: reactPackagesInstallCmd, + nestjs: nestPackagesInstallCmd, }; const eslintConfigCmds = { nextjs: reactEslintConfigCmd, + nestjs: nestEslintConfigCmd, }; async function init() { @@ -100,6 +136,7 @@ async function init() { const installRequiredPackages = packagesInstallCmds[technology]; + console.log("Installing required plugins..."); installRequiredPackages({ install, uninstall, devInstall }); execSync(`npm pkg set scripts.lint="next lint --fix`, { @@ -122,12 +159,7 @@ async function init() { stdio: "inherit", }); - const configNames = [ - ".gitattributes", - ".lintstagedrc.json", - ".prettierignore", - ".prettierrc.json", - ]; + const configNames = [".gitattributes", ".prettierignore"]; console.log("Coping configuration files"); const eslintConfigCmd = eslintConfigCmds[technology]; From 8a3a886ba96b686abe0bcaece56b6d39952a694b Mon Sep 17 00:00:00 2001 From: raj-vc Date: Wed, 20 Dec 2023 11:28:59 +0530 Subject: [PATCH 03/14] changes: update folder name --- config/{nextjs => react}/.eslintrc.json | 0 index.js | 10 +++++----- 2 files changed, 5 insertions(+), 5 deletions(-) rename config/{nextjs => react}/.eslintrc.json (100%) diff --git a/config/nextjs/.eslintrc.json b/config/react/.eslintrc.json similarity index 100% rename from config/nextjs/.eslintrc.json rename to config/react/.eslintrc.json diff --git a/index.js b/index.js index eb7b585..97d77a6 100644 --- a/index.js +++ b/index.js @@ -25,16 +25,16 @@ const reactPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { }; const reactEslintConfigCmd = () => { - const configPath = resolve(__dirname, `./config/nextjs/.eslintrc.json`); + const configPath = resolve(__dirname, `./config/react/.eslintrc.json`); copyFileSync(configPath, ".eslintrc.json"); }; const packagesInstallCmds = { - nextjs: reactPackagesInstallCmd, + react: reactPackagesInstallCmd, }; const eslintConfigCmds = { - nextjs: reactEslintConfigCmd, + react: reactEslintConfigCmd, }; async function init() { @@ -60,8 +60,8 @@ async function init() { message: "Select a technology", choices: [ { - name: "NextJs", - value: "nextjs", + name: "React", + value: "react", }, { name: "Angular", From ba4c2993aa001072484dca53012371d914797e6f Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Wed, 20 Dec 2023 07:41:07 +0000 Subject: [PATCH 04/14] resolve issue of not found page .prettierrc file --- config/nestjs/.lintstagedrc.json | 2 +- config/nestjs/{prettierrc => .prettierrc} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename config/nestjs/{prettierrc => .prettierrc} (100%) diff --git a/config/nestjs/.lintstagedrc.json b/config/nestjs/.lintstagedrc.json index b3cfe37..c4c131c 100644 --- a/config/nestjs/.lintstagedrc.json +++ b/config/nestjs/.lintstagedrc.json @@ -1,7 +1,7 @@ { "{src,apps,libs,test}/**/*.ts": [ "eslint --fix", - "prettier --config ./prettierrc --write" + "prettier --config ./.prettierrc --write" ], "{src,apps,libs,test}/**/*.json": [ "prettier --config ./.prettierrc --write" diff --git a/config/nestjs/prettierrc b/config/nestjs/.prettierrc similarity index 100% rename from config/nestjs/prettierrc rename to config/nestjs/.prettierrc From 8311dde90078367acfa8862aaf824eeb50d138a1 Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Wed, 20 Dec 2023 09:40:59 +0000 Subject: [PATCH 05/14] chanse path of lintstagedrc.json for react --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9604c68..229eecf 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,7 @@ const reactEslintConfigCmd = () => { ); const configPathForLintStage = resolve( __dirname, - `./config/nestjs/.lintstagedrc.json` + `./config/nextjs/.lintstagedrc.json` ); copyFileSync(configPath, ".eslintrc.json"); From 4a31e7cc4b3ac4ad832b68d17ed7df8e02a364df Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Thu, 21 Dec 2023 07:17:26 +0000 Subject: [PATCH 06/14] fix: max-length issue esLint rule --- config/nestjs/.eslintrc.js | 98 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/config/nestjs/.eslintrc.js b/config/nestjs/.eslintrc.js index c1e342b..a64bb37 100644 --- a/config/nestjs/.eslintrc.js +++ b/config/nestjs/.eslintrc.js @@ -1,82 +1,80 @@ module.exports = { - parser: "@typescript-eslint/parser", + parser: '@typescript-eslint/parser', parserOptions: { - project: "tsconfig.json", + project: 'tsconfig.json', tsconfigRootDir: __dirname, - sourceType: "module", + sourceType: 'module', }, - plugins: ["@typescript-eslint/eslint-plugin"], + plugins: ['@typescript-eslint/eslint-plugin'], extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', ], root: true, env: { node: true, jest: true, }, - ignorePatterns: [".eslintrc.js"], + ignorePatterns: ['.eslintrc.js'], rules: { - "@typescript-eslint/interface-name-prefix": "off", - "@typescript-eslint/explicit-function-return-type": "error", - "@typescript-eslint/explicit-module-boundary-types": "warn", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": "warn", - "@typescript-eslint/no-invalid-this": "off", - "@typescript-eslint/no-unused-expressions": "warn", - "@typescript-eslint/return-await": "warn", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/promise-function-async": "error", - "@typescript-eslint/prefer-optional-chain": "error", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/naming-convention": [ - "error", - { selector: "default", format: ["strictCamelCase"] }, + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'error', + '@typescript-eslint/explicit-module-boundary-types': 'warn', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/no-invalid-this': 'off', + '@typescript-eslint/no-unused-expressions': 'warn', + '@typescript-eslint/return-await': 'warn', + '@typescript-eslint/member-ordering': 'off', + '@typescript-eslint/promise-function-async': 'error', + '@typescript-eslint/prefer-optional-chain': 'error', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/naming-convention': [ + 'error', + { selector: 'default', format: ['strictCamelCase'] }, { - selector: "variable", - format: ["strictCamelCase", "UPPER_CASE", "PascalCase"], + selector: 'variable', + format: ['strictCamelCase', 'UPPER_CASE', 'PascalCase'], }, { - selector: "parameter", - modifiers: ["unused"], - format: ["strictCamelCase"], - leadingUnderscore: "allow", + selector: 'parameter', + modifiers: ['unused'], + format: ['strictCamelCase'], + leadingUnderscore: 'allow', }, - { selector: "property", format: null }, - { selector: "typeProperty", format: null }, - { selector: "typeLike", format: ["StrictPascalCase"] }, - { selector: "enumMember", format: ["UPPER_CASE"] }, + { selector: 'property', format: null }, + { selector: 'typeProperty', format: null }, + { selector: 'typeLike', format: ['StrictPascalCase'] }, + { selector: 'enumMember', format: ['UPPER_CASE'] }, ], - "no-useless-return": "error", - "no-constant-condition": "warn", - "max-len": [ - "error", + 'no-useless-return': 'error', + 'no-constant-condition': 'warn', + 'max-len': [ + 'error', { code: 200, - skipBlankLines: true, - skipComments: true, }, ], - "max-lines": [ - "error", + 'max-lines': [ + 'error', { max: 1000, }, ], - "no-multiple-empty-lines": [ - "error", + 'no-multiple-empty-lines': [ + 'error', { max: 2, maxEOF: 1, }, ], - "no-console": "error", - "no-mixed-operators": "error", - "keyword-spacing": "error", - "multiline-ternary": ["error", "never"], - "no-undef": "error", - "no-whitespace-before-property": "error", - "nonblock-statement-body-position": "error", + 'no-console': 'error', + 'no-mixed-operators': 'error', + 'keyword-spacing': 'error', + 'multiline-ternary': ['error', 'never'], + 'no-undef': 'error', + 'no-whitespace-before-property': 'error', + 'nonblock-statement-body-position': 'error', }, }; From d0150f58e911e8af6b5e8bbaf5face82c7506f7a Mon Sep 17 00:00:00 2001 From: Stavan Sanghvi Date: Thu, 21 Dec 2023 13:59:51 +0530 Subject: [PATCH 07/14] feat: Add Docs for the Config files --- docs/common/editor-settings.md | 36 +++++++++++++++++ docs/common/extensions.md | 25 ++++++++++++ docs/common/gitattributes.md | 16 ++++++++ docs/common/precommit.md | 21 ++++++++++ docs/react/eslintrc.md | 45 +++++++++++++++++++++ docs/react/lintstagedrc.md | 21 ++++++++++ docs/react/prettier.md | 71 ++++++++++++++++++++++++++++++++++ 7 files changed, 235 insertions(+) create mode 100644 docs/common/editor-settings.md create mode 100644 docs/common/extensions.md create mode 100644 docs/common/gitattributes.md create mode 100644 docs/common/precommit.md create mode 100644 docs/react/eslintrc.md create mode 100644 docs/react/lintstagedrc.md create mode 100644 docs/react/prettier.md diff --git a/docs/common/editor-settings.md b/docs/common/editor-settings.md new file mode 100644 index 0000000..3f6948a --- /dev/null +++ b/docs/common/editor-settings.md @@ -0,0 +1,36 @@ +# Visual Studio Code Settings (settings.json) + +## Overview + +The `settings.json` file configures Visual Studio Code (VSCode) settings to customize the editor's behavior and integrate with code formatting and linting tools. It is recommended to maintain consistent configurations across all developers' VSCode editors for a unified development experience. + +The `settings.json` file enhances the VSCode editor experience by enabling automatic code formatting on save and paste, specifying the default formatter, and defining code actions for ESLint and import organization. + +### Configuration Details + +- **`editor.formatOnSave`** + + - **Description:** Enables automatic code formatting when saving a file. + - **Value:** `true` + +- **`editor.formatOnPaste`** + + - **Description:** Enables automatic code formatting when pasting code into the editor. + - **Value:** `true` + +- **`editor.defaultFormatter`** + + - **Description:** Sets the default formatter for code formatting. + - **Value:** `"esbenp.prettier-vscode"` + +- **`editor.codeActionsOnSave`** + + - **Description:** Defines code actions to run on save. + - **Actions:** + - `source.fixAll.eslint`: Runs ESLint to fix all issues. + - `source.fixAll.format`: Runs the default formatter to fix formatting issues. + - `source.organizeImports`: Organizes imports in the source code. + +- **`files.eol`** + - **Description:** Specifies the default end-of-line (EOL) character. + - **Value:** `"\n"` diff --git a/docs/common/extensions.md b/docs/common/extensions.md new file mode 100644 index 0000000..1bf3dfb --- /dev/null +++ b/docs/common/extensions.md @@ -0,0 +1,25 @@ +# Visual Studio Code Extensions Recommendations (extensions.json) + +## Overview + +The `extensions.json` file provides a list of recommended Visual Studio Code extensions for developers working on a project. It is advisable for all team members to install these extensions to enhance productivity and maintain a consistent development environment. + +### Configuration Details + +- **`recommendations`** + - **Description:** Lists recommended extensions for Visual Studio Code. + - **Extensions:** + - `aaron-bond.better-comments`: Improves the styling and rendering of comments. + - `codeium.codeium`: Enhances collaboration by providing a collaborative coding platform which provides free AI code acceleration plugin for your favorite languages. + - `mikestead.dotenv`: Adds support for .env file syntax highlighting. + - `dbaeumer.vscode-eslint`: Integrates ESLint for JavaScript and TypeScript linting. + - `wix.vscode-import-cost`: Displays import costs for JavaScript and TypeScript. + - `visualstudioexptteam.vscodeintellicode`: Enhances code completion with machine learning. + - `yzhang.markdown-all-in-one`: Simplifies Markdown editing with various features. + - `christian-kohler.path-intellisense`: Autocompletes filenames in the editor. + - `esbenp.prettier-vscode`: Integrates Prettier for code formatting. + - `sonarsource.sonarlint-vscode`: Provides static code analysis to identify and fix code quality issues. + +## Conclusion + +The `extensions.json` file recommends essential Visual Studio Code extensions for a standardized and efficient development experience. Ensure that all team members install these extensions to maintain consistency across the development environment. diff --git a/docs/common/gitattributes.md b/docs/common/gitattributes.md new file mode 100644 index 0000000..977dee4 --- /dev/null +++ b/docs/common/gitattributes.md @@ -0,0 +1,16 @@ +# Git Attributes Configuration (.gitattributes) + +## Overview + +The `.gitattributes` file specifies attributes for files and directories in a Git repository. It helps define how Git should handle line endings and automatic text file detection. + +### Configuration Details + +- **Pattern: `*`** + - **Attributes:** + - `text=auto`: Instructs Git to automatically detect whether a file is a text file. + - `eol=lf`: Specifies the default end-of-line (EOL) character as Unix/Linux line endings (`LF`). + +## Conclusion + +The `.gitattributes` file ensures consistent handling of line endings and automatic text file detection in a Git repository. The specified configuration helps maintain cross-platform compatibility and a unified codebase. diff --git a/docs/common/precommit.md b/docs/common/precommit.md new file mode 100644 index 0000000..0f8344c --- /dev/null +++ b/docs/common/precommit.md @@ -0,0 +1,21 @@ +# Pre-commit Hook Configuration (precommit) + +## Overview + +The `precommit` file is a pre-commit hook configuration script used to automate tasks before committing changes. It leverages Husky and lint-staged to run specific commands on staged files before they are committed. + +### Configuration Details + +- **Script:** + + - **File Name:** `precommit` + - **Location:** Project root + - **Interpreter:** `/usr/bin/env sh` + +- **Commands:** + - **Husky Setup:** Sources the `husky.sh` script to set up Husky. + - **lint-staged:** Uses `npx` to run lint-staged, which executes specified tasks on staged files. + +## Conclusion + +The `precommit` script enhances the pre-commit workflow by automatically running tasks, such as linting staged files, before allowing a commit. This helps maintain code quality and consistency throughout the development process. diff --git a/docs/react/eslintrc.md b/docs/react/eslintrc.md new file mode 100644 index 0000000..f9c5c9e --- /dev/null +++ b/docs/react/eslintrc.md @@ -0,0 +1,45 @@ +# ESLint Configuration (.eslintrc.json) + +## Overview + +The `.eslintrc.json` file is used with ESLint, a JavaScript and TypeScript linter, to enforce coding standards, catch errors, and maintain a consistent codebase. + +The `.eslintrc.json` file is essential for enforcing coding standards and maintaining a consistent codebase in JavaScript and TypeScript projects. Customize based on project requirements. + +### `env` + +- **Description:** Specifies environments for ESLint. +- **Values:** + - `browser`: Enables browser global variables. + - `node`: Enables Node.js global variables. + +### `parser` + +- **Description:** Specifies the parser for code analysis. +- **Value:** `@typescript-eslint/parser` + +### `parserOptions` + +- **Description:** Configures parser options for ECMAScript and TypeScript. + +### `plugins` + +- **Description:** Lists ESLint plugins for linting specific code types. + - `react` + - `react-hooks` + - `promise` + - `import` + - `@typescript-eslint` + +### `ignorePatterns` + +- **Description:** Ignores specified file patterns. + +### `rules` + +- **Description:** Specifies ESLint rules and their configurations. + - `react/react-in-jsx-scope`: Turns off React import requirement. + - `jsx-a11y/anchor-is-valid`: Turns off anchor element validation. + - `@typescript-eslint/no-unused-vars`: Warns on unused TypeScript variables. + - `prettier/prettier`: Enforces Prettier code formatting rules. + - `promise/prefer-await-to-then`: Warns against using `.then()`. diff --git a/docs/react/lintstagedrc.md b/docs/react/lintstagedrc.md new file mode 100644 index 0000000..611444f --- /dev/null +++ b/docs/react/lintstagedrc.md @@ -0,0 +1,21 @@ +# lint-staged Configuration (.lintstagedrc.json) + +## Overview + +The `.lintstagedrc.json` file configures lint-staged, a Git pre-commit hook tool, to run specific tasks on files that are staged for commit. + +The `.lintstagedrc.json` file optimizes the pre-commit process by focusing linting and formatting tasks on staged files. Customize the configuration based on project requirements and coding conventions. + +### Configuration Details + +- **Pattern: `**/\*.{js,jsx,ts,tsx}`\*\* + + - **Description:** Targets JavaScript and TypeScript files for linting and formatting. + - **Tasks:** + - `eslint --fix`: Runs ESLint with the fix option to automatically correct linting issues. + - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. + +- **Pattern: `**/\*.{css,scss,md,html,json}`\*\* + - **Description:** Targets CSS, SCSS, Markdown, HTML, and JSON files for formatting. + - **Task:** + - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. diff --git a/docs/react/prettier.md b/docs/react/prettier.md new file mode 100644 index 0000000..562d035 --- /dev/null +++ b/docs/react/prettier.md @@ -0,0 +1,71 @@ +# Prettier Configuration (.prettierrc.json) + +## Overview + +The `.prettierrc.json` file is used with Prettier, a code formatter, to define code styling rules and formatting options. + +The `.prettierrc.json` file sets Prettier formatting rules, ensuring code consistency and adherence to styling preferences. Customize these settings according to project requirements and coding conventions. + +### Configuration Details + +- **`printWidth`** + + - **Description:** Specifies the maximum line length before wrapping. + - **Value:** `80` + +- **`singleQuote`** + + - **Description:** Determines whether single or double quotes are used for strings. + - **Value:** `false` + +- **`trailingComma`** + + - **Description:** Controls the usage of trailing commas in object literals and arrays. + - **Value:** `"es5"` + +- **`tabWidth`** + + - **Description:** Defines the number of spaces per indentation level. + - **Value:** `2` + +- **`endOfLine`** + - **Description:** Specifies the line ending style. + - **Value:** `"lf"` + +# Prettier Ignore File (.prettierignore) + +## Overview + +The `.prettierignore` file is used with Prettier, a code formatter, to specify files and directories that should be excluded from formatting. + +The `.prettierignore` file excludes files and directories from Prettier formatting. Customize this file based on project requirements and coding conventions. + +### Configuration Details + +- **Pattern: `.next`** + + - **Description:** Excludes the `.next` directory from formatting. + +- **Pattern: `.cache`** + + - **Description:** Excludes the `.cache` directory from formatting. + +- **Pattern: `package-lock.json`** + + - **Description:** Excludes the `package-lock.json` file from formatting. + +- **Pattern: `public`** + + - **Description:** Excludes the `public` directory from formatting. + +- **Pattern: `node_modules`** + + - **Description:** Excludes the `node_modules` directory from formatting. + +- **Pattern: `next-env.d.ts`** + + - **Description:** Excludes the `next-env.d.ts` file from formatting. + +- **Pattern: `next.config.ts`** + + - **Description:** Excludes the `next.config.ts` file from formatting. From 147c8fdda694c4c9c2e187e281fdea80e6e10720 Mon Sep 17 00:00:00 2001 From: Stavan Sanghvi Date: Thu, 21 Dec 2023 15:34:58 +0530 Subject: [PATCH 08/14] fix: Add extension detail to doc --- docs/common/extensions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/common/extensions.md b/docs/common/extensions.md index 1bf3dfb..b0f6ce2 100644 --- a/docs/common/extensions.md +++ b/docs/common/extensions.md @@ -18,6 +18,7 @@ The `extensions.json` file provides a list of recommended Visual Studio Code ext - `yzhang.markdown-all-in-one`: Simplifies Markdown editing with various features. - `christian-kohler.path-intellisense`: Autocompletes filenames in the editor. - `esbenp.prettier-vscode`: Integrates Prettier for code formatting. + - `chakrounanas.turbo-console-log`: Adds a shortcut to console.log statements. - `sonarsource.sonarlint-vscode`: Provides static code analysis to identify and fix code quality issues. ## Conclusion From 3b8b59de03d42b10691c13c5601bbfbd2234bdcb Mon Sep 17 00:00:00 2001 From: vc-vishakha Date: Fri, 22 Dec 2023 16:26:53 +0530 Subject: [PATCH 09/14] feat: Added angular lint config --- config/angular/.eslintrc.json | 88 +++++++++++++++++++++++++++++++ config/angular/.lintstagedrc.json | 9 ++++ config/angular/.prettierrc.json | 21 ++++++++ config/common/.prettierignore | 3 +- config/common/extensions.json | 4 +- index.js | 39 ++++++++++++-- 6 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 config/angular/.eslintrc.json create mode 100644 config/angular/.lintstagedrc.json create mode 100644 config/angular/.prettierrc.json diff --git a/config/angular/.eslintrc.json b/config/angular/.eslintrc.json new file mode 100644 index 0000000..e5da84c --- /dev/null +++ b/config/angular/.eslintrc.json @@ -0,0 +1,88 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@angular-eslint/recommended", + "plugin:@angular-eslint/template/process-inline-templates", + "plugin:@typescript-eslint/eslint-recommended" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ], + "max-len": [ + "error", + { + "code": 120 + } + ], + "semi": [ + "error", + "always" + ], + "@typescript-eslint/member-delimiter-style": [ + "warn", + { + "multiline": { + "delimiter": "semi", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": true + } + } + ], + "no-magic-numbers": [ + "warn", + { + "ignoreArrayIndexes": true, + "ignoreDefaultValues": true, + "ignoreClassFieldInitialValues": true, + "ignore": [ + -1, + 0, + 1 + ] + } + ], + "no-console": "error", + "no-extra-boolean-cast": "off" + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended", + "plugin:@angular-eslint/template/accessibility" + ], + "rules": { + "prefer-template": 1 + } + } + ] +} \ No newline at end of file diff --git a/config/angular/.lintstagedrc.json b/config/angular/.lintstagedrc.json new file mode 100644 index 0000000..081c90b --- /dev/null +++ b/config/angular/.lintstagedrc.json @@ -0,0 +1,9 @@ +{ + "**/*.{js,ts}": [ + "eslint --fix", + "prettier --config ./.prettierrc.json --write" + ], + "**/*.{css,scss,md,html,json}": [ + "prettier --config ./.prettierrc.json --write" + ] +} diff --git a/config/angular/.prettierrc.json b/config/angular/.prettierrc.json new file mode 100644 index 0000000..eff3818 --- /dev/null +++ b/config/angular/.prettierrc.json @@ -0,0 +1,21 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "trailingComma": "es5", + "singleQuote": true, + "semi": true, + "bracketSpacing": true, + "endOfLine": "lf", + "overrides": [ + { + "files": [ + "**/*.css", + "**/*.scss", + "**/*.html" + ], + "options": { + "singleQuote": false + } + } + ] +} \ No newline at end of file diff --git a/config/common/.prettierignore b/config/common/.prettierignore index 9c403ae..944b105 100644 --- a/config/common/.prettierignore +++ b/config/common/.prettierignore @@ -5,4 +5,5 @@ dist public node_modules next-env.d.ts -next.config.ts \ No newline at end of file +next.config.ts +/.angular/cache \ No newline at end of file diff --git a/config/common/extensions.json b/config/common/extensions.json index fd7817d..a1c52f2 100644 --- a/config/common/extensions.json +++ b/config/common/extensions.json @@ -10,7 +10,7 @@ "christian-kohler.path-intellisense", "esbenp.prettier-vscode", "chakrounanas.turbo-console-log", - "sonarsource.sonarlint-vscode" - + "sonarsource.sonarlint-vscode", + "eamodio.gitlens" ] } \ No newline at end of file diff --git a/index.js b/index.js index a87bbf3..dd14236 100644 --- a/index.js +++ b/index.js @@ -32,6 +32,15 @@ const nestPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { ); }; +const angularPackagesInstallCmd = ({ install, devInstall, forceCMD }) => { + execSync( + `${install} @types/node eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin @angular-eslint/builder @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/schematics @angular-eslint/template-parser husky lint-staged prettier ${devInstall} ${forceCMD}`, + { + stdio: "inherit", + } + ); +}; + const reactEslintConfigCmd = () => { const configPath = resolve(__dirname, `./config/react/.eslintrc.json`); const configPathForPrettier = resolve( @@ -63,14 +72,32 @@ const nestEslintConfigCmd = () => { copyFileSync(configPathForLintStage, ".lintstagedrc.json"); }; +const angularEslintConfigCmd = () => { + const configPath = resolve(__dirname, `./config/angular/.eslintrc.json`); + const configPathForPrettier = resolve( + __dirname, + `./config/angular/.prettierrc.json` + ); + const configPathForLintStage = resolve( + __dirname, + `./config/angular/.lintstagedrc.json` + ); + + copyFileSync(configPath, ".eslintrc.json"); + copyFileSync(configPathForPrettier, ".prettierrc.json"); + copyFileSync(configPathForLintStage, ".lintstagedrc.json"); +}; + const packagesInstallCmds = { react: reactPackagesInstallCmd, nestjs: nestPackagesInstallCmd, + angular: angularPackagesInstallCmd, }; const eslintConfigCmds = { react: reactEslintConfigCmd, nestjs: nestEslintConfigCmd, + angular: angularEslintConfigCmd, }; async function init() { @@ -137,9 +164,15 @@ async function init() { const installRequiredPackages = packagesInstallCmds[technology]; console.log("Installing required plugins..."); - installRequiredPackages({ install, uninstall, devInstall }); + installRequiredPackages({ install, forceCMD, devInstall }); + + const eslintRunCmds = { + react: 'next lint --fix', + nestjs: 'npm run lint', + angular: 'ng lint', + }; - execSync(`npm pkg set scripts.lint="next lint --fix`, { + execSync(`npm pkg set scripts.lint="${eslintRunCmds[technology]}`, { stdio: "inherit", }); @@ -174,7 +207,7 @@ async function init() { const preCommitConfigPath = resolve(__dirname, "./config/common/pre-commit"); copyFileSync(preCommitConfigPath, "./.husky/pre-commit"); - mkdir("./.vscode", () => {}); + mkdir("./.vscode", () => { }); const vscodeConfigPath = resolve(__dirname, "./config/common/settings.json"); const vscodeExtensionsPath = resolve( From 597def5573d74b25e4f009ba6319fded4927e5de Mon Sep 17 00:00:00 2001 From: Stavan Sanghvi Date: Wed, 27 Dec 2023 12:59:13 +0530 Subject: [PATCH 10/14] feat: Add GitLens Extension Details --- docs/common/extensions.md | 1 + docs/react/lintstagedrc.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/common/extensions.md b/docs/common/extensions.md index b0f6ce2..ad07a97 100644 --- a/docs/common/extensions.md +++ b/docs/common/extensions.md @@ -20,6 +20,7 @@ The `extensions.json` file provides a list of recommended Visual Studio Code ext - `esbenp.prettier-vscode`: Integrates Prettier for code formatting. - `chakrounanas.turbo-console-log`: Adds a shortcut to console.log statements. - `sonarsource.sonarlint-vscode`: Provides static code analysis to identify and fix code quality issues. + - `eamodio.gitlens`: Enhances Git integration with features like commit history exploration and blame annotations. ## Conclusion diff --git a/docs/react/lintstagedrc.md b/docs/react/lintstagedrc.md index 611444f..8434260 100644 --- a/docs/react/lintstagedrc.md +++ b/docs/react/lintstagedrc.md @@ -8,14 +8,14 @@ The `.lintstagedrc.json` file optimizes the pre-commit process by focusing linti ### Configuration Details -- **Pattern: `**/\*.{js,jsx,ts,tsx}`\*\* +- **Pattern: `**/\*.{js,jsx,ts,tsx}`** - **Description:** Targets JavaScript and TypeScript files for linting and formatting. - **Tasks:** - `eslint --fix`: Runs ESLint with the fix option to automatically correct linting issues. - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. -- **Pattern: `**/\*.{css,scss,md,html,json}`\*\* +- **Pattern: `**/\*.{css,scss,md,html,json}`** - **Description:** Targets CSS, SCSS, Markdown, HTML, and JSON files for formatting. - **Task:** - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. From b41f53563c19dbe8726281859cfe480b948c4fa0 Mon Sep 17 00:00:00 2001 From: vc-vishakha Date: Wed, 27 Dec 2023 18:28:49 +0530 Subject: [PATCH 11/14] feat: Add docs for angular config files --- docs/angular/eslintrc.md | 52 ++++++++++++++++++++++++++++++++ docs/angular/lintstagedrc.md | 21 +++++++++++++ docs/angular/prettier.md | 57 ++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 docs/angular/eslintrc.md create mode 100644 docs/angular/lintstagedrc.md create mode 100644 docs/angular/prettier.md diff --git a/docs/angular/eslintrc.md b/docs/angular/eslintrc.md new file mode 100644 index 0000000..f8b186d --- /dev/null +++ b/docs/angular/eslintrc.md @@ -0,0 +1,52 @@ +# ESLint Configuration (.eslintrc.json) + +## Overview + +The `.eslintrc.json` file is used with ESLint, a JavaScript and TypeScript linter, to enforce coding standards, catch errors, and maintain a consistent codebase. + +The `.eslintrc.json` file is essential for enforcing coding standards and maintaining a consistent codebase in TypeScript and Angular projects. Customize based on project requirements. + +### `root` + +- **Description:** Indicates that this `.eslintrc.json` is the root configuration file. +- **Value:** `true` + +### `ignorePatterns` + +- **Description:** Defines patterns for files and directories to be ignored by ESLint. +- **Value:** + - `projects/**/*`: Ignores all files under the `projects` directory. + +### `overrides` + +#### TypeScript Files (`*.ts`) + +- **Description:** Configuration specifically for TypeScript files. + + - `extends` + - `eslint:recommended`: Inherits recommended ESLint rules. + - `plugin:@typescript-eslint/recommended`: Includes recommended TypeScript ESLint rules. + - `plugin:@angular-eslint/recommended`: Integrates recommended Angular ESLint rules. + - `plugin:@angular-eslint/template/process-inline-templates`: Handles inline template processing for Angular. + - `plugin:@typescript-eslint/eslint-recommended`: Recommends ESLint rules for TypeScript from TypeScript ESLint. + + - `rules` + - `@angular-eslint/directive-selector`: Specifies directives' naming conventions. + - `@angular-eslint/component-selector`: Specifies component naming conventions. + - `max-len`: Sets maximum line length to 120 characters. + - `semi`: Enforces the usage of semicolons. + - `@typescript-eslint/member-delimiter-style`: Specifies member delimiter style for TypeScript. + - `no-magic-numbers`: Disallows magic numbers except for specific cases. + - `no-console`: Disallows the usage of `console` statements. + - `no-extra-boolean-cast`: Allows extra boolean casts. + +#### HTML Files (`*.html`) + +- **Description:** Configuration specifically for HTML files. + + - `extends` + - `plugin:@angular-eslint/template/recommended`: Incorporates recommended Angular template ESLint rules. + - `plugin:@angular-eslint/template/accessibility`: Focuses on template accessibility rules. + + - `rules` + - `prefer-template`: Encourages the use of template literals in HTML. diff --git a/docs/angular/lintstagedrc.md b/docs/angular/lintstagedrc.md new file mode 100644 index 0000000..acb5666 --- /dev/null +++ b/docs/angular/lintstagedrc.md @@ -0,0 +1,21 @@ +# lint-staged Configuration (.lintstagedrc.json) + +## Overview + +The `.lintstagedrc.json` file configures lint-staged, a Git pre-commit hook tool, to run specific tasks on files that are staged for commit. + +The `.lintstagedrc.json` file optimizes the pre-commit process by focusing linting and formatting tasks on staged files. Customize the configuration based on project requirements and coding conventions. + +### Configuration Details + +- **Pattern: `**/\*.{js,ts}`** + + - **Description:** Targets JavaScript and TypeScript files for linting and formatting. + - **Tasks:** + - `eslint --fix`: Runs ESLint with the fix option to automatically correct linting issues. + - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. + +- **Pattern: `**/\*.{css,scss,md,html,json}`** + - **Description:** Targets CSS, SCSS, Markdown, HTML, and JSON files for formatting. + - **Task:** + - `prettier --config ./.prettierrc.json --write`: Runs Prettier with a specific configuration file to format code. diff --git a/docs/angular/prettier.md b/docs/angular/prettier.md new file mode 100644 index 0000000..f8bd3d0 --- /dev/null +++ b/docs/angular/prettier.md @@ -0,0 +1,57 @@ +# Prettier Configuration (.prettierrc.json) + +## Overview + +The `.prettierrc.json` file is used with Prettier, a code formatter, to define code styling rules and formatting options. + +The `.prettierrc.json` file sets Prettier formatting rules, ensuring code consistency and adherence to styling preferences. Customize these settings according to project requirements and coding conventions. + + +### `printWidth` + +- **Description:** Specifies the maximum line width before wrapping. +- **Value:** `80` + +### `tabWidth` + +- **Description:** Specifies the number of spaces per indentation-level. +- **Value:** `2` + +### `trailingComma` + +- **Description:** Controls the usage of trailing commas in object literals and arrays. +- **Value:** `"es5"` + +### `singleQuote` + +- **Description:** Defines whether to use single quotes instead of double quotes for strings. +- **Value:** `true` + +### `semi` + +- **Description:** Indicates whether to add a semicolon at the end of statements. +- **Value:** `true` + +### `bracketSpacing` + +- **Description:** Controls whether to add spaces inside object literals' curly braces. +- **Value:** `true` + +### `endOfLine` + +- **Description:** Specifies the type of line endings. +- **Value:** `"lf"` + +### `overrides` + +- **Description:** Allows specific configurations for certain file types. + + #### CSS, SCSS, HTML Files + + - `files` + - `"**/*.css"` + - `"**/*.scss"` + - `"**/*.html"` + - `options` + - `singleQuote`: `false` (Overrides single quotes for these file types) + From ac1c27592ed52abfbc3bcb83a9290f50227c3c6c Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Thu, 28 Dec 2023 05:18:23 +0000 Subject: [PATCH 12/14] fixed: change EsLint run commnad for nestjs --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index dd14236..851e773 100644 --- a/index.js +++ b/index.js @@ -168,7 +168,7 @@ async function init() { const eslintRunCmds = { react: 'next lint --fix', - nestjs: 'npm run lint', + nestjs: 'eslint \"{src,apps,libs,test}/**/*.ts\" --fix', angular: 'ng lint', }; From bd870d7206408b14e5ccef2b46eda667be3cf01e Mon Sep 17 00:00:00 2001 From: Lb Madesia Date: Fri, 29 Dec 2023 09:47:49 +0000 Subject: [PATCH 13/14] documentation: ESLint and Prettier config documentation for nestjs --- docs/nestjs/eslintrc.md | 63 ++++++++++++++++++++++++++++++++++ docs/nestjs/lintstagedrc.md | 21 ++++++++++++ docs/nestjs/prettier.md | 67 +++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 docs/nestjs/eslintrc.md create mode 100644 docs/nestjs/lintstagedrc.md create mode 100644 docs/nestjs/prettier.md diff --git a/docs/nestjs/eslintrc.md b/docs/nestjs/eslintrc.md new file mode 100644 index 0000000..41c1be7 --- /dev/null +++ b/docs/nestjs/eslintrc.md @@ -0,0 +1,63 @@ +# ESLint Configuration (.eslintrc.json) + +## Overview + +The `.eslintrc.js` file is used with ESLint, a TypeScript linter, to enforce coding standards, catch errors, and maintain a consistent codebase. + +The `.eslintrc.js` file is essential for enforcing coding standards and maintaining a consistent codebase in TypeScript projects. Customize based on project requirements. + + +### `parser` + +- **Description:** Specifies the parser for code analysis. +- **Value:** `@typescript-eslint/parser` + +### `parserOptions` + +- **Description:** Configures parser options for ECMAScript and TypeScript. + +### `plugins` + +- **Description:** Lists the ESLint plugins being utilized, with a focus on TypeScript. + - `@typescript-eslint/eslint-plugin` + +### `Extends` + +- **Description:** Inherits configurations from recommended ESLint and TypeScript plugins, as well as the Prettier plugin. + - `plugin:@typescript-eslint/recommended` + - `plugin:prettier/recommended` + - `plugin:@typescript-eslint/recommended-requiring-type-checking` + +### `Root` + +- **Description:** Indicates that ESLint should stop looking for configuration files in parent directories. + +- ### `Environment` + +- **Description:** Specifies environments for ESLint. +- **Values:** + - `jest`: Enables jest global variables for testing. + - `node`: Enables Node.js global variables. + +### `ignorePatterns` + +- **Description:** Ignores specified file patterns. + +### `rules` + +- **Description:** Specifies ESLint rules and their configurations. + - `@typescript-eslint/interface-name-prefix`: Disables the requirement for interface names to have a prefix. + - `@typescript-eslint/explicit-function-return-type`: Enforces explicit return types for functions. + - `@typescript-eslint/naming-convention`: Defines naming conventions for various code elements. + - `no-useless-return`: Flags unnecessary return statements. + - `max-len`: Enforces a maximum line length of 200 characters. + - `max-lines`: Sets a maximum number of lines in a file (1000 lines). + - `no-console`: Prohibits the use of console statements. + - `no-constant-condition`: Warns against the use of constant conditions in conditional statements, as they may be unintentional. + - `no-multiple-empty-lines`: Enforces a maximum number of consecutive empty lines, both at the end and within the code. + - `no-mixed-operators`: Warns against the use of mixed operators without parentheses, which can lead to confusion. + - `keyword-spacing`: Enforces consistent spacing around keywords like if, else, and return for improved readability. + - `multiline-ternary`: Enforces a specific style for multiline ternary operators to enhance code clarity. + - `no-undef`: Flags the usage of undeclared variables, helping to catch potential runtime errors. + - `no-whitespace-before-property`: Disallows whitespace before properties in object literals for consistent styling. + - `nonblock-statement-body-position`: Enforces a consistent position for the opening brace of non-block statements (e.g., if statements) for better readability. diff --git a/docs/nestjs/lintstagedrc.md b/docs/nestjs/lintstagedrc.md new file mode 100644 index 0000000..260d2a4 --- /dev/null +++ b/docs/nestjs/lintstagedrc.md @@ -0,0 +1,21 @@ +# lint-staged Configuration (.lintstagedrc.json) + +## Overview + +The `.lintstagedrc.json` file configures lint-staged, a Git pre-commit hook tool, to run specific tasks on files that are staged for commit. + +The `.lintstagedrc.json` file optimizes the pre-commit process by focusing linting and formatting tasks on staged files. Customize the configuration based on project requirements and coding conventions. + +### Configuration Details + +- **Pattern: `{src,apps,libs,test}/**/*.ts`** + + - **Description:** Targets TypeScript files in src,apps,libs and test folder for linting and formatting. + - **Tasks:** + - `eslint --fix`: Runs ESLint with the fix option to automatically correct linting issues. + - `prettier --config ./.prettierrc --write`: Runs Prettier with a specific configuration file to format code. + +- **Pattern: `{src,apps,libs,test}/**/*.json`** + - **Description:** Targets JSON files for formatting. + - **Task:** + - `prettier --config ./.prettierrc --write`: Runs Prettier with a specific configuration file to format code. diff --git a/docs/nestjs/prettier.md b/docs/nestjs/prettier.md new file mode 100644 index 0000000..b212203 --- /dev/null +++ b/docs/nestjs/prettier.md @@ -0,0 +1,67 @@ +# Prettier Configuration (.prettierrc.json) + +## Overview + +The `.prettierrc.json` file is used with Prettier, a code formatter, to define code styling rules and formatting options. + +The `.prettierrc.json` file sets Prettier formatting rules, ensuring code consistency and adherence to styling preferences. Customize these settings according to project requirements and coding conventions. + +### Configuration Details + +- **`singleQuote`** + + - **Description:** Enables the use of single quotes for string literals. + - **Value:** `true` + +- **`semi`** + + - **Description:** Enforces the use of semicolons at the end of statements. + - **Value:** `true` + +- **`tabWidth`** + + - **Description:** Specifies the number of spaces for an indentation level. + - **Value:** `2` + +- **`trailingComma`** + + - **Description:** Configures the placement of trailing commas in object literals, arrays, and function parameters. + - **Value:** `all` + +- **`printWidth`** + + - **Description:** Specifies the maximum line length before wrapping. + - **Value:** `80` + +- **`endOfLine`** + - **Description:** Specifies the line ending style. + - **Value:** `"lf"` + +# Prettier Ignore File (.prettierignore) + +## Overview + +The `.prettierignore` file is used with Prettier, a code formatter, to specify files and directories that should be excluded from formatting. + +The `.prettierignore` file excludes files and directories from Prettier formatting. Customize this file based on project requirements and coding conventions. + +### Configuration Details + + + +- **Pattern: `package-lock.json`** + + - **Description:** Excludes the `package-lock.json` file from formatting. + +- **Pattern: `dist`** + + - **Description:** Excludes the `dist` directory from formatting. + +- **Pattern: `public`** + + - **Description:** Excludes the `public` directory from formatting. + +- **Pattern: `node_modules`** + + - **Description:** Excludes the `node_modules` directory from formatting. + From 1077fc6138bcf5c6d60f56ed93b8f1777463b07c Mon Sep 17 00:00:00 2001 From: raj-vc Date: Wed, 3 Jan 2024 12:56:02 +0530 Subject: [PATCH 14/14] docs: added config docs and bump version and update changelog --- CHANGELOG.md | 8 ++++++++ package.json | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48f78f4..988938a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +_Jan 3, 2024_ + +- Added support for the Angular( [@vc-vishakha](https://github.com/vc-vishakha) in [#7](https://github.com/vcian/lint-sage/pull/7) ) +- Added support for the Nestjs( [@vc-lbmadesia](https://github.com/vc-lbmadesia) in [#5](https://github.com/vcian/lint-sage/pull/5) ). +- Added Documentation for configs in Angular, Next js and Nest js. + ## 1.1.1 _Dec 8, 2023_ diff --git a/package.json b/package.json index e91516f..6c2c80d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vcian/lint-sage", - "version": "1.1.1", + "version": "2.0.0", "description": "This package designed to simplify the configuration of your projects. This package automates the setup of essential tools and configurations to ensure a clean and consistent codebase.", "bin": { "lint-sage": "index.js" @@ -21,7 +21,12 @@ "lint", "husky", "vscode", - "reactjs" + "nextjs", + "reactjs", + "angular", + "nodejs", + "nestjs", + "typescript" ], "license": "MIT", "bugs": {