Skip to content

Commit

Permalink
Merge pull request #11 from vcian/development
Browse files Browse the repository at this point in the history
Added Support for Angular and Nestjs along with Docs
  • Loading branch information
palaklive authored Jan 3, 2024
2 parents fbbb3f7 + 1077fc6 commit 15d2b7f
Show file tree
Hide file tree
Showing 30 changed files with 882 additions and 31 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
88 changes: 88 additions & 0 deletions config/angular/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
9 changes: 9 additions & 0 deletions config/angular/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"**/*.{js,ts}": [
"eslint --fix",
"prettier --config ./.prettierrc.json --write"
],
"**/*.{css,scss,md,html,json}": [
"prettier --config ./.prettierrc.json --write"
]
}
21 changes: 21 additions & 0 deletions config/angular/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
File renamed without changes.
4 changes: 3 additions & 1 deletion config/.prettierignore → config/common/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.next
.cache
package-lock.json
dist
public
node_modules
next-env.d.ts
next.config.ts
next.config.ts
/.angular/cache
4 changes: 3 additions & 1 deletion config/extensions.json → config/common/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"yzhang.markdown-all-in-one",
"christian-kohler.path-intellisense",
"esbenp.prettier-vscode",
"sonarsource.sonarlint-vscode"
"chakrounanas.turbo-console-log",
"sonarsource.sonarlint-vscode",
"eamodio.gitlens"
]
}
File renamed without changes.
File renamed without changes.
80 changes: 80 additions & 0 deletions config/nestjs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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,
},
],
'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',
},
};
9 changes: 9 additions & 0 deletions config/nestjs/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"{src,apps,libs,test}/**/*.ts": [
"eslint --fix",
"prettier --config ./.prettierrc --write"
],
"{src,apps,libs,test}/**/*.json": [
"prettier --config ./.prettierrc --write"
]
}
8 changes: 8 additions & 0 deletions config/nestjs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"singleQuote": true,
"semi": true,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 80,
"endOfLine": "auto"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions docs/angular/eslintrc.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions docs/angular/lintstagedrc.md
Original file line number Diff line number Diff line change
@@ -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.
57 changes: 57 additions & 0 deletions docs/angular/prettier.md
Original file line number Diff line number Diff line change
@@ -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)

Loading

0 comments on commit 15d2b7f

Please sign in to comment.