Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
261 changes: 0 additions & 261 deletions .eslintrc.yaml

This file was deleted.

94 changes: 61 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ Since the 0.0.4 release, some rules defined in [John Papa's Guideline](https://g
npm install --save-dev eslint-plugin-angular
```

3. Use the shareable config by adding it to your `.eslintrc`:

```yaml
extends: plugin:angular/johnpapa
3. Use the shareable config by adding it to your `eslintrc.config.mjs`:

```javascript
import angular from "eslint-plugin-angular";

export default defineConfig([{
plugins: {
angular
},
rules: {
...angular.configs.johnpapa.rules
}
}]);
```


Expand All @@ -63,19 +72,30 @@ Since the 0.0.4 release, some rules defined in [John Papa's Guideline](https://g
npm install --save-dev eslint-plugin-angular
```

3. Enable the plugin by adding it to your `.eslintrc`:
3. Enable the plugin by adding it to your `eslint.config.mjs`:

```yaml
plugins:
- angular
```
4. You can also configure these rules in your `.eslintrc`. All rules defined in this plugin have to be prefixed by 'angular/'
```javascript
import angular from "eslint-plugin-angular";

```yaml
plugins:
- angular
rules:
- angular/controller_name: 0
export default defineConfig([{
plugins: {
angular
}
}]);
```
4. You can also configure these rules in your `eslint.config.mjs`. All rules defined in this plugin have to be prefixed by 'angular/'

```javascript
import angular from "eslint-plugin-angular";

export default defineConfig([{
plugins: {
angular
},
rules: {
"angular/controller-name": "error"
}
}]);
```

----
Expand Down Expand Up @@ -248,20 +268,28 @@ There are some useful references for creating new rules. Specificly useful are:

We can use a property, defined in the ESLint configuration file, in order to know which version is used : Angular 1 or Angular 2. based on this property, you can create rules for each version.

```yaml
plugins:
- angular

rules:
angular/controller-name:
- 2
- '/[A-Z].*Controller$/'

globals:
angular: true

settings:
angular: 2
```javascript
import angular from "eslint-plugin-angular";

export default defineConfig([
{
files: ["**/*.js"],
plugins: {
angular
},
languageOptions: {
globals: {
angular: true
}
},
settings: {
angular: 2
},
rules: {
"angular/controller-name": ["error", "/[A-Z].*Controller$/"]
}
}
]);
```

And in your rule, you can access to this property thanks to the `context` object :
Expand All @@ -285,10 +313,10 @@ return {

Here is the basic configuration for the rules defined in the ESLint plugin, in order to be compatible with the guideline provided by @johnpapa :

```yaml
rules:
no-use-before-define:
- 0
```javascript
rules: {
"no-use-before-define": "off"
}
```


Expand Down
Loading