@jeroenpol/eslint-config 1.0.0 → 1.0.1

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/.eslintrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "files": ["*.ts", "*.tsx"],
3
+ "parser": "@typescript-eslint/parser",
4
+ "extends": "./index.js",
5
+ "rules": {}
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ 1.0.0 / 2024-08-07
2
+ ==================
3
+ - [major] Release
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2012 Airbnb
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,25 @@
1
+ # polware eslint-config <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
+
3
+ [![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)][package-url]
4
+
5
+ ## Usage
6
+
7
+ Use this esLint config as a basis for you Angular projects.
8
+
9
+ ### Installation
10
+
11
+ ```sh
12
+ npm i --save-dev jeroenpol/eslint-config
13
+ ```
14
+
15
+ 1. Install the correct versions of each package, which are listed by the command:
16
+
17
+ ```sh
18
+ npm info "jeroenpol/eslint-config@latest" peerDependencies
19
+ ```
20
+
21
+ If using **npm 5+**, use this shortcut
22
+
23
+ ```sh
24
+ npx install-peerdeps --dev polware/eslint-config
25
+ ```
@@ -3,25 +3,28 @@ module.exports = {
3
3
  {
4
4
  files: ['*.ts', '*.tsx'],
5
5
  parser: '@typescript-eslint/parser',
6
- parserOptions: {
7
- ecmaVersion: 2020,
8
- sourceType: 'module',
9
- project: './tsconfig.*json',
10
- },
11
- plugins: ['@typescript-eslint', 'rxjs-angular', 'sonarjs'],
6
+ plugins: ['@typescript-eslint', 'rxjs-angular', 'sonarjs', 'redundant-undefined'],
12
7
  rules: {
13
8
  // Code complexity rules
14
9
  'max-depth': ['error', 3], // Goal value: 2
15
10
  'max-nested-callbacks': ['error', 5], // Goal value: 2-3
16
- "max-statements-per-line": ['error', { "max": 1 }],
17
- 'complexity': ['error', { max: 8 }], // GOAL VALUE: 7
11
+ 'max-statements-per-line': ['error', { max: 1 }],
12
+ complexity: ['error', { max: 8 }], // GOAL VALUE: 7
18
13
  'sonarjs/cognitive-complexity': ['error', 10], // GOAL VALUE: 6
19
14
 
20
15
  // Prevent code smells
21
- 'max-lines-per-function': ['error', {'max': 60, 'skipBlankLines': true, 'skipComments': true}], // Goal value: 40
16
+ 'max-lines-per-function': ['error', { max: 60, skipBlankLines: true, skipComments: true }], // Goal value: 40
22
17
  'max-statements': ['error', 20], // Goal value: 16-18?
23
18
  'sonarjs/max-switch-cases': ['error', 10],
24
19
  'sonarjs/no-nested-switch': 'error',
20
+ 'default-case-last': 'error',
21
+ 'default-param-last': 'error',
22
+ 'sonarjs/no-small-switch': 'error',
23
+ 'sonarjs/no-identical-functions': 'error',
24
+ 'sonarjs/no-redundant-jump': 'error',
25
+ 'no-empty-function': ['error', { allow: ['constructors'] }],
26
+ 'redundant-undefined/redundant-undefined': 'error',
27
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
25
28
 
26
29
  // Prevent accidental bugs
27
30
  'no-param-reassign': 'error',
@@ -38,7 +41,7 @@ module.exports = {
38
41
  '@typescript-eslint/no-non-null-assertion': 'error',
39
42
 
40
43
  // Type safety
41
- '@typescript-eslint/no-explicit-any': 'warn', // TODO: set to error
44
+ '@typescript-eslint/no-explicit-any': 'error',
42
45
  '@typescript-eslint/explicit-function-return-type': ['error', { allowHigherOrderFunctions: true }],
43
46
 
44
47
  // Disable JS features
@@ -46,7 +49,6 @@ module.exports = {
46
49
  'no-console': 'error',
47
50
 
48
51
  // Disabled ESLint rules
49
- '@typescript-eslint/array-type': 'off',
50
52
  '@typescript-eslint/interface-name-prefix': 'off',
51
53
  'max-classes-per-file': 'off',
52
54
  '@typescript-eslint/no-inferrable-types': 'off',
@@ -57,6 +59,7 @@ module.exports = {
57
59
 
58
60
  // Conventions
59
61
  'no-array-constructor': 'error',
62
+ '@typescript-eslint/array-type': 'error',
60
63
  'quote-props': ['warn', 'as-needed'],
61
64
  '@typescript-eslint/ban-types': [
62
65
  'error',
@@ -103,14 +106,14 @@ module.exports = {
103
106
  ],
104
107
 
105
108
  // Performance improvements + preventing memory leaks
106
- "rxjs-angular/prefer-takeuntil": [
107
- "error",
109
+ 'rxjs-angular/prefer-takeuntil': [
110
+ 'error',
108
111
  {
109
- "alias": ["untilDestroyed"],
110
- "checkComplete": true,
111
- "checkDecorators": ["Component"],
112
- "checkDestroy": true
113
- }
112
+ alias: ['untilDestroyed', 'takeUntilDestroyed'],
113
+ checkDecorators: ['Component'],
114
+ checkComplete: false,
115
+ checkDestroy: false,
116
+ },
114
117
  ],
115
118
  },
116
119
  },
@@ -1,16 +1,16 @@
1
1
  module.exports = {
2
2
  rules: {
3
3
  '@typescript-eslint/explicit-member-accessibility': 'off',
4
+ '@angular-eslint/use-lifecycle-interface': ['error'],
5
+ '@angular-eslint/sort-lifecycle-methods': ['error'],
6
+ '@angular-eslint/no-lifecycle-call': ['error'],
7
+ '@angular-eslint/no-empty-lifecycle-method': ['error'],
8
+ '@angular-eslint/no-async-lifecycle-method': ['error'],
4
9
  },
5
10
  overrides: [
6
11
  {
7
12
  files: ['*.ts', '*.tsx'],
8
13
  parser: '@typescript-eslint/parser',
9
- parserOptions: {
10
- ecmaVersion: 2020,
11
- sourceType: 'module',
12
- project: './tsconfig.*json',
13
- },
14
14
  plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'],
15
15
  rules: {
16
16
  'array-bracket-newline': ['warn', 'consistent'],
@@ -35,14 +35,14 @@ module.exports = {
35
35
  curly: ['warn', 'all'],
36
36
  'dot-location': ['warn', 'property'],
37
37
  'eol-last': 'warn',
38
- 'func-call-spacing': 'warn',
38
+ '@typescript-eslint/func-call-spacing': 'error',
39
39
  'function-call-argument-newline': ['warn', 'consistent'],
40
40
  'function-paren-newline': ['warn', 'multiline-arguments'],
41
41
  'generator-star-spacing': 'off',
42
42
  'implicit-arrow-linebreak': 'off',
43
43
  indent: 'off',
44
44
  '@typescript-eslint/indent': [
45
- 'warn',
45
+ 'error',
46
46
  2,
47
47
  {
48
48
  SwitchCase: 1,
@@ -57,7 +57,7 @@ module.exports = {
57
57
 
58
58
  'keyword-spacing': 'off', // overridden by @typescript-eslint
59
59
  '@typescript-eslint/keyword-spacing': ['warn', { after: true, before: true }],
60
-
60
+ '@typescript-eslint/type-annotation-spacing': 'warn',
61
61
  'linebreak-style': 'off',
62
62
  'max-len': [
63
63
  'error',
@@ -81,18 +81,18 @@ module.exports = {
81
81
  'no-mixed-operators': ['error'],
82
82
  'no-mixed-spaces-and-tabs': 'error',
83
83
  'no-multi-spaces': 'error',
84
- 'no-multiple-empty-lines': ['warn', { max: 1 }], // overwritten NG default
84
+ 'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 0, maxBOF: 0 }], // overwritten NG default
85
85
  'no-tabs': 'error',
86
86
  'no-trailing-spaces': 'warn',
87
87
  'no-unexpected-multiline': 'error',
88
-
89
- "@typescript-eslint/no-unused-vars": "off",
90
- "unused-imports/no-unused-imports": "error",
91
- "unused-imports/no-unused-vars": [
92
- "warn",
93
- { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
88
+ 'no-unused-vars': 'off', // off: conflict unused-imports/no-unused-vars
89
+ '@typescript-eslint/no-unused-vars': 'off', // off: conflict unused-imports/no-unused-vars
90
+ 'unused-imports/no-unused-imports': 'error',
91
+ 'unused-imports/no-unused-vars': [
92
+ 'error',
93
+ { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
94
94
  ],
95
- 'no-duplicate-imports': 'warn',
95
+ 'no-duplicate-imports': 'error',
96
96
 
97
97
  'no-useless-constructor': 'off', // overridden by @typescript-eslint
98
98
  '@typescript-eslint/no-useless-constructor': ['error'],
@@ -122,6 +122,7 @@ module.exports = {
122
122
  'space-before-function-paren': ['warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
123
123
  'space-in-parens': 'warn',
124
124
  'space-infix-ops': 'warn',
125
+ '@typescript-eslint/space-infix-ops': 'warn',
125
126
  'space-unary-ops': 'warn',
126
127
  'switch-colon-spacing': 'warn',
127
128
  'template-curly-spacing': 'warn',
@@ -131,9 +132,9 @@ module.exports = {
131
132
  'yield-star-spacing': 'error',
132
133
  'no-unused-expressions': 'error',
133
134
  'prefer-const': 'error',
134
- 'id-length': ['error', { 'min': 2, 'properties': 'never', 'exceptions': ['i', 'e', 'a', 'b', '_'] }], // TODO: remove some of these exceptions
135
+ 'id-length': ['error', { min: 2, properties: 'never', exceptions: ['i', 'e', 'a', 'b', 'x', 'y', '_'] }], // TODO: remove some of these exceptions
135
136
  '@typescript-eslint/no-parameter-properties': 'off',
136
- '@typescript-eslint/member-ordering': ['warn'],
137
+ '@typescript-eslint/member-ordering': ['error'],
137
138
  '@typescript-eslint/explicit-member-accessibility': [
138
139
  'error',
139
140
  {
@@ -6,7 +6,6 @@ module.exports = {
6
6
  parserOptions: {
7
7
  ecmaVersion: 2020,
8
8
  sourceType: 'module',
9
- project: './tsconfig.*json',
10
9
  },
11
10
  plugins: ['@typescript-eslint', 'simple-import-sort'],
12
11
  rules: {
@@ -15,6 +14,7 @@ module.exports = {
15
14
  'simple-import-sort/exports': 'error',
16
15
  'sort-imports': 'off',
17
16
  'import/order': 'off',
17
+ '@typescript-eslint/no-require-imports': 'error',
18
18
  'no-restricted-imports': [
19
19
  'error',
20
20
  {
package/index.js CHANGED
@@ -1 +1,12 @@
1
- module.exports = require('./.eslintrc.json')
1
+ module.exports = {
2
+ extends: [
3
+ './configuration/best-practices.js',
4
+ './configuration/code-style.js',
5
+ './configuration/imports.js',
6
+ ].map(require.resolve),
7
+ parserOptions: {
8
+ ecmaVersion: 2020,
9
+ sourceType: 'module',
10
+ },
11
+ rules: {},
12
+ };
package/package.json CHANGED
@@ -1,71 +1,62 @@
1
1
  {
2
2
  "name": "@jeroenpol/eslint-config",
3
- "version": "1.0.0",
4
- "description": "eslint-config as configured by Jeroen Pol",
3
+ "version": "1.0.1",
4
+ "description": "ES Lint config made for Angular, configured by Polware",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./configuration/best-practices": "./configuration/best-practices.js",
9
+ "./configuration/code-style": "./configuration/code-style.js",
10
+ "./configuration/imports": "./configuration/imports.js",
11
+ "./package.json": "./package.json"
8
12
  },
13
+ "scripts": {},
9
14
  "repository": {
10
15
  "type": "git",
11
- "url": "git+https://github.com/jeroenpol/eslint-config.git"
16
+ "url": "https://github.com/airbnb/javascript"
12
17
  },
13
18
  "keywords": [
14
- "JavaScript Standard Style",
15
- "check",
16
- "checker",
17
- "code",
18
- "code checker",
19
- "code linter",
20
- "code standards",
21
- "code style",
22
- "enforce",
23
19
  "eslint",
24
20
  "eslintconfig",
25
- "hint",
26
- "jscs",
27
- "jshint",
28
- "lint",
29
- "eslint",
30
- "es-lint",
31
- "policy",
32
- "quality",
33
- "simple",
34
- "standard",
35
- "standard style",
36
- "style",
37
- "style checker",
38
- "style linter",
39
- "verify",
40
- "TypeScript"
21
+ "config",
22
+ "javascript",
23
+ "typescript",
24
+ "angular",
25
+ "styleguide",
26
+ "polware"
27
+ ],
28
+ "author": "Jeroen Pol (https://www.linkedin.com/in/jeroenpol)",
29
+ "contributors": [
30
+ {
31
+ "name": "Jeroen Pol",
32
+ "url": "https://www.linkedin.com/in/jeroenpol"
33
+ }
41
34
  ],
42
- "author": "Jeroen Pol",
43
- "license": "ISC",
35
+ "license": "MIT",
44
36
  "bugs": {
45
- "url": "https://github.com/jeroenpol/eslint-config/issues"
37
+ "url": "https://github.com/TOADD"
46
38
  },
47
- "homepage": "https://github.com/jeroenpol/eslint-config#readme",
48
- "dependencies": {
49
- "@typescript-eslint/parser": "^5.43.0"
39
+ "homepage": "https://github.com/TOADD",
40
+ "devDependencies": {
41
+ "eslint": "8.57.0",
42
+ "eslint-config-prettier": "9.1.0",
43
+ "eslint-plugin-functional": "6.5.1",
44
+ "eslint-plugin-redundant-undefined": "^1.0.0",
45
+ "eslint-plugin-rxjs-angular": "2.0.1",
46
+ "eslint-plugin-simple-import-sort": "10.0.0",
47
+ "eslint-plugin-sonarjs": "1.0.3",
48
+ "eslint-plugin-unused-imports": "3.2.0",
49
+ "@typescript-eslint/eslint-plugin": "6.19.0",
50
+ "@typescript-eslint/parser": "^6.19.0"
50
51
  },
51
52
  "peerDependencies": {
52
- "@typescript-eslint/eslint-plugin": "^5.43.0",
53
- "eslint": "^8.0.1",
54
- "eslint-plugin-import": "^2.25.2",
55
- "eslint-plugin-n": "^15.0.0",
56
- "eslint-plugin-promise": "^6.0.0",
57
- "typescript": "*"
53
+ "eslint": "8.57.0",
54
+ "eslint-plugin-import": "^2.29.1"
58
55
  },
59
- "devDependencies": {
60
- "@typescript-eslint/eslint-plugin": "^5.57.1",
61
- "@typescript-eslint/parser": "^5.57.1",
62
- "eslint": "^8.38.0",
63
- "eslint-config-prettier": "^8.8.0",
64
- "eslint-plugin-functional": "^5.0.7",
65
- "eslint-plugin-rxjs-angular": "^2.0.0",
66
- "eslint-plugin-simple-import-sort": "^10.0.0",
67
- "eslint-plugin-sonarjs": "^0.19.0",
68
- "eslint-plugin-unused-imports": "^2.0.0",
69
- "typescript": "^5.0.4"
56
+ "engines": {
57
+ "node": "20"
58
+ },
59
+ "dependencies": {
60
+ "confusing-browser-globals": "^1.0.11"
70
61
  }
71
- }
62
+ }