@jkba/eslint-config-angular 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) 2023 Jakub Meinlschmidt
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,55 @@
1
+ # eslint-config-angular
2
+
3
+ Opinionated ESLint config for Angular projects
4
+
5
+
6
+ ## Installation
7
+
8
+ For some unknown weird reason, following dependencies have to be installed in your project as well. (https://github.com/jmeinlschmidt/eslint-config-angular/issues/5)
9
+
10
+ ```sh
11
+ npm i -D eslint-plugin-rxjs eslint-plugin-rxjs-angular
12
+ ```
13
+
14
+ ```sh
15
+ npm i -D @jkba/eslint-config-angular
16
+ ```
17
+
18
+
19
+ ## Usage
20
+
21
+ Extend your eslint configuration with `"@jkba/angular"`:
22
+
23
+ ```javascript
24
+ // .eslintrc.json
25
+
26
+ {
27
+ "extends": [ "@jkba/angular" ]
28
+ }
29
+ ```
30
+
31
+ Create prettier configuration file:
32
+
33
+ ```javascript
34
+ // prettier.config.js
35
+
36
+ module.exports = require('@jkba/eslint-config-angular/prettier.config');
37
+ ```
38
+
39
+
40
+ ### Modifying rules
41
+
42
+ > :warning: Work in Progress
43
+
44
+
45
+ ## Build
46
+
47
+ > :warning: Work in Progress
48
+
49
+ Refer to https://eslint.org/docs/latest/extend/shareable-configs.
50
+
51
+
52
+ ## License
53
+
54
+ This project is licensed under [MIT License](http://opensource.org/licenses/MIT/).
55
+ For the full text of the license, see the [LICENSE](LICENSE) file.
@@ -0,0 +1,123 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: [
5
+ '*.ts'
6
+ ],
7
+ parser: '@typescript-eslint/parser',
8
+ parserOptions: {
9
+ ecmaVersion: 2019,
10
+ project: './tsconfig.json',
11
+ sourceType: 'module',
12
+ },
13
+ extends: [
14
+ 'eslint:recommended',
15
+ 'plugin:@typescript-eslint/stylistic-type-checked',
16
+ 'plugin:@typescript-eslint/strict-type-checked',
17
+ 'plugin:@angular-eslint/recommended',
18
+ 'plugin:@angular-eslint/template/process-inline-templates',
19
+ 'plugin:rxjs/recommended', // For some unknown weird reason, this plugin needs to be installed in child project as well.
20
+ 'plugin:import/recommended',
21
+ 'plugin:import/typescript',
22
+
23
+ // Prettier rule must always be the very last!
24
+ // This rule might intentionally disable some rules declared above due to conflicts
25
+ 'plugin:prettier/recommended',
26
+ ],
27
+ plugins: ['@typescript-eslint', '@angular-eslint', 'rxjs', 'rxjs-angular'],
28
+ settings: {
29
+ // Reference https://www.npmjs.com/package/eslint-plugin-import
30
+ 'import/resolver': {
31
+ // You will also need to install and configure the TypeScript resolver
32
+ // See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
33
+ 'typescript': true,
34
+ 'node': true,
35
+ }
36
+ },
37
+ rules: {
38
+ 'no-warning-comments': [ 'error', { 'terms': ['todo', 'fixme'], 'location': 'anywhere' } ],
39
+ 'no-console': 'error',
40
+
41
+ /**
42
+ * Declaration sort is handled by import/order rule.
43
+ * This rule handles order within {}-brackets only.
44
+ */
45
+ 'sort-imports': [ 'error', { 'ignoreDeclarationSort': true }],
46
+
47
+ 'rxjs-angular/prefer-async-pipe': 'error',
48
+ 'rxjs-angular/prefer-composition': 'error',
49
+ 'rxjs-angular/prefer-takeuntil': 'error',
50
+
51
+ '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }], // Ignore `Validators.required` etc.
52
+ '@typescript-eslint/no-confusing-void-expression': 'off', // I just simply disagree with this rule
53
+ '@typescript-eslint/explicit-member-accessibility': [
54
+ 'error', { 'overrides': { 'constructors': 'no-public' } }
55
+ ],
56
+
57
+ '@angular-eslint/sort-ngmodule-metadata-arrays': 'error',
58
+ '@angular-eslint/prefer-on-push-component-change-detection': 'error',
59
+ '@angular-eslint/use-component-view-encapsulation': 'warn', // For me, it is only a suggestion
60
+ '@angular-eslint/prefer-output-readonly': 'error', // TODO: Not working (does nothing)
61
+ '@angular-eslint/contextual-decorator': 'error',
62
+ '@angular-eslint/component-max-inline-declarations': [ 'error', { 'template': 20 } ],
63
+ '@angular-eslint/contextual-decorator': 'error',
64
+ '@angular-eslint/no-attribute-decorator': 'error',
65
+ '@angular-eslint/no-conflicting-lifecycle': 'error',
66
+ '@angular-eslint/no-empty-lifecycle-method': 'error',
67
+ '@angular-eslint/no-forward-ref': 'warn', // For me, it is only a suggestion
68
+ '@angular-eslint/no-input-prefix': 'error',
69
+ '@angular-eslint/no-lifecycle-call': 'error',
70
+ '@angular-eslint/no-pipe-impure': 'error',
71
+ '@angular-eslint/no-queries-metadata-property': 'error',
72
+ '@angular-eslint/prefer-standalone-component': 'error',
73
+ '@angular-eslint/relative-url-prefix': 'error',
74
+ // '@angular-eslint/require-localize-metadata': 'error', // TODO: Error
75
+ '@angular-eslint/use-component-selector': 'error',
76
+
77
+ 'import/no-absolute-path': 'error',
78
+ 'import/newline-after-import': [ 'error', { 'count': 1 } ],
79
+ 'import/order': [
80
+ 'error',
81
+ {
82
+ 'groups': ['builtin', 'external', 'parent', 'sibling', 'index'],
83
+ 'newlines-between': 'always',
84
+ 'alphabetize': {
85
+ 'order': 'asc',
86
+ 'caseInsensitive': true
87
+ }
88
+ }
89
+ ],
90
+ },
91
+ },
92
+ {
93
+ files: [
94
+ '*.html'
95
+ ],
96
+ parser: '@angular-eslint/template-parser',
97
+ extends: [
98
+ 'plugin:@angular-eslint/template/accessibility',
99
+ 'plugin:@angular-eslint/template/recommended',
100
+
101
+ // Prettier rule must always be the very last!
102
+ // This rule might intentionally disable some rules declared above due to conflicts
103
+ 'plugin:prettier/recommended',
104
+ ],
105
+ plugins: ['@angular-eslint/template'],
106
+ rules: {
107
+ // '@angular-eslint/template/attributes-order': 'error', // TODO: Bug present (https://github.com/angular-eslint/angular-eslint/issues/1456)
108
+ '@angular-eslint/template/button-has-type': 'warn', // For me, it is only a suggestion
109
+ '@angular-eslint/template/no-inline-styles': 'warn', // For me, it is only a suggestion
110
+ '@angular-eslint/template/conditional-complexity': [
111
+ 'error', { 'maxComplexity': 3 } // Max 3 is enough, create derived variable with proper naming
112
+ ],
113
+ '@angular-eslint/template/i18n': 'error',
114
+ '@angular-eslint/template/no-any': 'error',
115
+ '@angular-eslint/template/no-call-expression': 'error',
116
+ '@angular-eslint/template/no-duplicate-attributes': 'error',
117
+ '@angular-eslint/template/no-interpolation-in-attributes': 'error',
118
+ '@angular-eslint/template/prefer-self-closing-tags': 'error',
119
+ '@angular-eslint/template/use-track-by-function': 'error'
120
+ }
121
+ },
122
+ ],
123
+ }
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const eslintconfig = require('./eslint.config.js');
2
+
3
+ module.exports = eslintconfig;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@jkba/eslint-config-angular",
3
+ "version": "1.0.0",
4
+ "description": "Opinionated ESLint config for Angular projects",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/jmeinlschmidt/eslint-config-angular.git"
12
+ },
13
+ "keywords": [
14
+ "eslint",
15
+ "eslintconfig",
16
+ "angular",
17
+ "lint"
18
+ ],
19
+ "files": [
20
+ "LICENSE",
21
+ "README.md",
22
+ "eslint.config.js",
23
+ "index.js",
24
+ "package.json",
25
+ "prettier.config.js"
26
+ ],
27
+ "author": "Jakub Meinlschmidt",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/jmeinlschmidt/eslint-config-angular/issues"
31
+ },
32
+ "homepage": "https://github.com/jmeinlschmidt/eslint-config-angular#readme",
33
+ "peerDependencies": {
34
+ "eslint": ">=8",
35
+ "prettier": ">=3",
36
+ "rxjs": ">=7",
37
+ "typescript": ">=4"
38
+ },
39
+ "dependencies": {
40
+ "@angular-eslint/eslint-plugin": "^16.0.0",
41
+ "@angular-eslint/eslint-plugin-template": "^16.0.0",
42
+ "@angular-eslint/template-parser": "^16.0.0",
43
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
44
+ "@typescript-eslint/parser": "^6.0.0",
45
+ "eslint-plugin-import": "^2.27.5",
46
+ "eslint-plugin-prettier": "^5.0.0",
47
+ "eslint-plugin-rxjs": "^5.0.3",
48
+ "eslint-plugin-rxjs-angular": "^2.0.1"
49
+ }
50
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ singleQuote: true,
3
+ tabWidth: 2,
4
+ bracketSameLine: true,
5
+ useTabs: false,
6
+ trailingComma: 'all',
7
+ semi: true,
8
+ bracketSpacing: true,
9
+ printWidth: 100,
10
+ arrowParens: 'always',
11
+ }