@intech.lu/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.md +7 -0
- package/README.md +90 -0
- package/eslint.config.mjs +109 -0
- package/package.json +53 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 InTech S.A.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# InTech Angular ESLint rules
|
|
2
|
+
|
|
3
|
+
Welcome to the "InTech Angular ESLint rules" repository, a centralized solution for managing and applying consistent code quality standards accross all projects at InTech using Angular. This repository hosts a custom ESLint configuration designed to enforce a unified coding style and coding best practices helping to ensure maintainability and reducing code quality discrepancies in collaborative projects.
|
|
4
|
+
|
|
5
|
+
## 🗂️ Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Installation](#⚙️-installation)
|
|
8
|
+
1. [Requirements](#📋-requirements)
|
|
9
|
+
2. [Step 1: install the ESLint extension for VSCode](#1️⃣-step-1-install-the-eslint-extension-for-vscode)
|
|
10
|
+
3. [Step 2: install ESLint and the InTech rules](#2️⃣-step-2-install-eslint-and-the-intech-rules)
|
|
11
|
+
4. [Step 3: create the ESLint configuration](#3️⃣-step-3-create-the-eslint-configuration)
|
|
12
|
+
5. [Step 4: enjoy 🎉](#4️⃣-step-4-enjoy-🎉)
|
|
13
|
+
2. [Contribute](#🤝-contribute)
|
|
14
|
+
1. [Development](#💻-development)
|
|
15
|
+
2. [Deployment](#🚀-deployment)
|
|
16
|
+
|
|
17
|
+
## ⚙️ Installation
|
|
18
|
+
|
|
19
|
+
Add the InTech Angular ESLint rules on your existing project.
|
|
20
|
+
|
|
21
|
+
### 📋 Requirements
|
|
22
|
+
|
|
23
|
+
- NPM version >= 9
|
|
24
|
+
- Node.js version >= `18.18.0`
|
|
25
|
+
- Angular version >= `18.0.0`
|
|
26
|
+
|
|
27
|
+
#### Supported versions
|
|
28
|
+
|
|
29
|
+
| Angular | InTech Angular ESLint |
|
|
30
|
+
| ------------------ | --------------------- |
|
|
31
|
+
| >= 18.0.0 | >= 2.0.0 |
|
|
32
|
+
| < 18.0.0 | >=1.0.0 <2.0.0 |
|
|
33
|
+
|
|
34
|
+
### 1️⃣ Step 1: install the ESLint extension for VSCode
|
|
35
|
+
|
|
36
|
+
- <https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint>
|
|
37
|
+
|
|
38
|
+
Create a `.vscode/settings.json` file with the following configuration at the root of your project:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"editor.codeActionsOnSave": {
|
|
43
|
+
"source.fixAll.eslint": true
|
|
44
|
+
},
|
|
45
|
+
"eslint.validate": ["javascript", "typescript", "html"]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2️⃣ Step 2: install ESLint and the InTech rules
|
|
50
|
+
|
|
51
|
+
Go to the folder of your project and execute the following command:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install -D eslint '@intech.lu/eslint-config-angular'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Note: *You'll have to install ESLint at least version 9 as it includes breaking changes and reworks the way ESLint is executed.*
|
|
58
|
+
|
|
59
|
+
### 3️⃣ Step 3: create the ESLint configuration
|
|
60
|
+
|
|
61
|
+
At the root of your project, create an `eslint.config.mjs` file with the following content:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import eslintConfig from '@intech.lu/eslint-config-angular';
|
|
65
|
+
|
|
66
|
+
export default [
|
|
67
|
+
...eslintConfig,
|
|
68
|
+
];
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
If you need to override the InTech rules for some reason, simply do it by adding rules in your `eslint.config.mjs`, it will override the InTech related ones:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import eslintConfig from '@intech.lu/eslint-config-angular';
|
|
75
|
+
|
|
76
|
+
export default [
|
|
77
|
+
...eslintConfig,
|
|
78
|
+
{
|
|
79
|
+
rules: {
|
|
80
|
+
'no-console': 'error', // will switch InTech 'no-console' rule value from 'warn' to 'error'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
⚠️ *NB: You should always override InTech rules after destructuring `eslintConfig`, otherwise `eslintConfig` will take precedence and override the rules you've just added.*
|
|
87
|
+
|
|
88
|
+
### 4️⃣ Step 4: enjoy 🎉
|
|
89
|
+
|
|
90
|
+
You now have the InTech Angular ESLint rules applied automatically to your project.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import angular from 'angular-eslint';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import eslintConfig from '@intech.lu/eslint-config';
|
|
4
|
+
|
|
5
|
+
export default defineConfig(
|
|
6
|
+
...eslintConfig,
|
|
7
|
+
{
|
|
8
|
+
files: ["**/*.ts"],
|
|
9
|
+
extends: [
|
|
10
|
+
...angular.configs.tsAll,
|
|
11
|
+
],
|
|
12
|
+
processor: angular.processInlineTemplates,
|
|
13
|
+
rules: {
|
|
14
|
+
// @angular-eslint already has a rule for this but only allows
|
|
15
|
+
// "Component" suffixes. This rule adds support for "Page"
|
|
16
|
+
// and "Modal" suffixes.
|
|
17
|
+
'@angular-eslint/component-class-suffix': [
|
|
18
|
+
'error',
|
|
19
|
+
{
|
|
20
|
+
suffixes: ['Component', 'Page', 'Modal'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
// Kebab case is the recommended way to name Angular components,
|
|
24
|
+
// so we want to enforce this naming convention.
|
|
25
|
+
// https://angular.dev/style-guide#component-selectors
|
|
26
|
+
'@angular-eslint/component-selector': [
|
|
27
|
+
'error',
|
|
28
|
+
{
|
|
29
|
+
type: 'element',
|
|
30
|
+
style: 'kebab-case',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
// Lower camel case is the recommended way to name Angular
|
|
34
|
+
// directives, so we want to enforce this naming convention.
|
|
35
|
+
// https://angular.dev/style-guide#directive-selectors
|
|
36
|
+
'@angular-eslint/directive-selector': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
type: 'attribute',
|
|
40
|
+
style: 'camelCase',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
// Empty functions should not go in production code, as they are a sign of
|
|
44
|
+
// a mistake or a leftover from development. Just add a comment in the function
|
|
45
|
+
// body to explain why it's empty and the error will go away.
|
|
46
|
+
// However, we want to allow empty constructors, as they are common in Angular
|
|
47
|
+
// for dependency injection (when not using inject() method) or to inject
|
|
48
|
+
// data in modal components.
|
|
49
|
+
'no-empty-function': ['error', { allow: ['constructors'] }],
|
|
50
|
+
// Members are public by default in TypeScript classes, so we
|
|
51
|
+
// don't need to explicitly declare them as public.
|
|
52
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
53
|
+
'error',
|
|
54
|
+
{
|
|
55
|
+
accessibility: 'no-public',
|
|
56
|
+
ignoredMethodNames: [
|
|
57
|
+
'ngOnInit',
|
|
58
|
+
'ngAfterViewInit',
|
|
59
|
+
'ngAfterContentInit',
|
|
60
|
+
'ngDoCheck',
|
|
61
|
+
'ngAfterViewChecked',
|
|
62
|
+
'ngAfterContentChecked',
|
|
63
|
+
'ngOnChanges',
|
|
64
|
+
'ngOnDestroy',
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
// Angular uses decorators to define props of a component,
|
|
69
|
+
// which is changing with the introduction of signals. But still,
|
|
70
|
+
// we want to enforce decorators to be places before constructor
|
|
71
|
+
// and members.
|
|
72
|
+
'@typescript-eslint/member-ordering': [
|
|
73
|
+
'error',
|
|
74
|
+
{
|
|
75
|
+
default: {
|
|
76
|
+
memberTypes: [
|
|
77
|
+
'signature',
|
|
78
|
+
'decorated-field',
|
|
79
|
+
'field',
|
|
80
|
+
'constructor',
|
|
81
|
+
'method',
|
|
82
|
+
],
|
|
83
|
+
order: 'as-written',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
"@typescript-eslint/no-extraneous-class": [
|
|
88
|
+
"error",
|
|
89
|
+
{
|
|
90
|
+
allowWithDecorator: true,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
files: ["**/*.html"],
|
|
97
|
+
extends: [
|
|
98
|
+
...angular.configs.templateRecommended,
|
|
99
|
+
...angular.configs.templateAll,
|
|
100
|
+
],
|
|
101
|
+
rules: {
|
|
102
|
+
// Even if it's not considered a good practice, it really too handy to call expressions
|
|
103
|
+
// in Angular templates and reduce the amount of logic in the component class.
|
|
104
|
+
'@angular-eslint/template/no-call-expression': 'off',
|
|
105
|
+
// A project don't necessarily use Angular i18n, so we disable this rule.
|
|
106
|
+
'@angular-eslint/template/i18n': 'off',
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intech.lu/eslint-config-angular",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ESLint rules for InTech Angular projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"style guide",
|
|
7
|
+
"lint",
|
|
8
|
+
"eslint",
|
|
9
|
+
"prettier",
|
|
10
|
+
"format",
|
|
11
|
+
"intech",
|
|
12
|
+
"angular"
|
|
13
|
+
],
|
|
14
|
+
"author": "InTech S.A. <equipe.titane@intech.lu> (https://www.intech.lu)",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
},
|
|
18
|
+
"contributors": [
|
|
19
|
+
{
|
|
20
|
+
"name": "Tristan Chaumont",
|
|
21
|
+
"email": "tristan.chaumont@intech.lu"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Loïc Gasiorowski",
|
|
25
|
+
"email": "loic.gasiorowski@intech.lu"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "Silvio Brancati",
|
|
29
|
+
"email": "silvio.brancati@intech.lu"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "Jacques Vernay",
|
|
33
|
+
"email": "jacques.vernay@intech.lu"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"repository": "github:intech-lu/eslint-config-angular",
|
|
37
|
+
"homepage": "github:intech-lu/eslint-config-angular",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"files": [
|
|
40
|
+
"eslint.config.mjs"
|
|
41
|
+
],
|
|
42
|
+
"main": "eslint.config.mjs",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"angular-eslint": "^20.4.0",
|
|
45
|
+
"@intech.lu/eslint-config": "1.0.1"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"eslint": "^9.35.0"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.18.0"
|
|
52
|
+
}
|
|
53
|
+
}
|