1
- # @stencil-community /eslint-plugin
1
+ # @stencil/eslint-plugin
2
2
3
3
ESLint rules specific to Stencil JS projects.
4
4
5
5
## Installation
6
6
7
- If you're using npm v7+, you only need to install this package. Its peer dependencies will be automatically installed.
8
- ``` bash
9
- npm i --save-dev @stencil-community/eslint-plugin
10
- ```
11
-
12
- If you're using npm v6 or lower, you will need to install this package and its peer dependencies in your stencil project:
7
+ Install this plugin in your project via:
13
8
14
9
``` bash
15
- npm i --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react @ stencil-community /eslint-plugin typescript
10
+ npm i --save-dev @ stencil/eslint-plugin
16
11
```
17
12
18
13
## Usage
19
14
20
- ### Configuration (legacy: .eslintrc* )
21
-
22
- ` .eslintrc.json ` configuration file:
23
-
24
- ``` json
25
- {
26
- "parserOptions" : {
27
- "project" : " ./tsconfig.json"
28
- },
29
- "extends" : [
30
- " plugin:@stencil-community/recommended"
31
- ]
32
- }
33
- ```
34
-
35
15
### Configuration (new: eslint.config.* )
36
16
37
17
The plugin exports 3 flat configs for use with eslint >= 9:
@@ -40,34 +20,33 @@ The plugin exports 3 flat configs for use with eslint >= 9:
40
20
- flat.recommended
41
21
- flat.strict
42
22
43
-
44
23
``` js
45
- // eslint.config.js
46
- const stencilLint = require ( ' @stencil-community /eslint-plugin' ) ;
24
+ // eslint.config.mjs
25
+ import stencil from ' @stencil/eslint-plugin' ;
47
26
48
- module . exports = [
27
+ export default [
49
28
...
50
- stencilLint .configs .flat .recommended ,
29
+ stencil .configs .flat .recommended ,
51
30
...
52
31
];
53
32
```
54
33
55
34
Alternatively:
56
35
57
36
``` js
58
- // eslint.config.mjs
59
- import stencilLint from ' @stencil-community /eslint-plugin' ;
37
+ // eslint.config.js
38
+ const stencil = require ( ' @stencil/eslint-plugin' ) ;
60
39
61
- export default [
40
+ module . exports = [
62
41
...
63
- stencilLint .configs .flat .recommended ,
42
+ stencil .configs .flat .recommended ,
64
43
...
65
44
];
66
45
```
67
46
68
-
69
47
By default, ESLint will ignore your ` node_modules/ ` directory. Consider adding a ` .eslintignore ` file at the root of
70
48
your project with any output target directories to avoid false positive errors from ESLint.
49
+
71
50
```
72
51
# place any directories created by the Stencil compilation process here
73
52
dist
@@ -76,104 +55,120 @@ www
76
55
```
77
56
78
57
Lint all your project:
79
- ```
58
+
59
+ ``` sh
80
60
npm run lint
81
61
```
82
62
63
+ ### Configuration (legacy: .eslintrc* )
64
+
65
+ ` .eslintrc.json ` configuration file:
66
+
67
+ ``` json
68
+ {
69
+ "parserOptions" : {
70
+ "project" : " ./tsconfig.json"
71
+ },
72
+ "extends" : [
73
+ " plugin:stencil/recommended"
74
+ ]
75
+ }
76
+ ```
77
+
83
78
## Supported Rules
84
79
85
- - [ ` @ stencil-community /async-methods` ] ( ./docs/async-methods.md )
80
+ - [ ` stencil/async-methods ` ] ( ./docs/async-methods.md )
86
81
87
82
This rule catches Stencil public methods that are not async.
88
83
89
- - [ ` @ stencil-community /ban-default-true` ] ( ./docs/ban-default-true.md )
84
+ - [ ` stencil/ban-default-true ` ] ( ./docs/ban-default-true.md )
90
85
91
86
This rule catches Stencil Props with a default value of ` true ` .
92
87
93
- - [ ` @ stencil-community /ban-prefix` ] ( ./docs/ban-prefix.md )
88
+ - [ ` stencil/ban-prefix ` ] ( ./docs/ban-prefix.md )
94
89
95
90
This rule catches Stencil Component banned tag name prefix.
96
91
97
- - [ ` @ stencil-community /class-pattern` ] ( ./docs/class-pattern.md )
92
+ - [ ` stencil/class-pattern ` ] ( ./docs/class-pattern.md )
98
93
99
94
This rule catches Stencil Component class name not matching configurable pattern.
100
95
101
- - [ ` @ stencil-community /decorators-context` ] ( ./docs/decorators-context.md )
96
+ - [ ` stencil/decorators-context ` ] ( ./docs/decorators-context.md )
102
97
103
98
This rule catches Stencil decorators in bad locations.
104
99
105
- - [ ` @ stencil-community /decorators-style` ] ( ./docs/decorators-style.md )
100
+ - [ ` stencil/decorators-style ` ] ( ./docs/decorators-style.md )
106
101
107
102
This rule catches Stencil decorators style usage.
108
103
109
- - [ ` @ stencil-community /element-type` ] ( ./docs/element-type.md )
104
+ - [ ` stencil/element-type ` ] ( ./docs/element-type.md )
110
105
111
106
This rule catches Stencil Element decorator have the correct type.
112
107
113
- - [ ` @ stencil-community /host-data-deprecated` ] ( ./docs/host-data-deprecated.md )
108
+ - [ ` stencil/host-data-deprecated ` ] ( ./docs/host-data-deprecated.md )
114
109
115
110
This rule catches Stencil method hostData.
116
111
117
- - [ ` @ stencil-community /methods-must-be-public` ] ( ./docs/methods-must-be-public.md )
112
+ - [ ` stencil/methods-must-be-public ` ] ( ./docs/methods-must-be-public.md )
118
113
119
114
This rule catches Stencil Methods marked as private or protected.
120
115
121
- - [ ` @ stencil-community /no-unused-watch` ] ( ./docs/no-unused-watch.md )
116
+ - [ ` stencil/no-unused-watch ` ] ( ./docs/no-unused-watch.md )
122
117
123
118
This rule catches Stencil Watchs with non existing Props or States.
124
119
125
- - [ ` @ stencil-community /own-methods-must-be-private` ] ( ./docs/own-methods-must-be-private.md )
120
+ - [ ` stencil/own-methods-must-be-private ` ] ( ./docs/own-methods-must-be-private.md )
126
121
127
122
This rule catches own class methods marked as public.
128
123
129
- - [ ` @ stencil-community /own-props-must-be-private` ] ( ./docs/own-props-must-be-private.md )
124
+ - [ ` stencil/own-props-must-be-private ` ] ( ./docs/own-props-must-be-private.md )
130
125
131
126
This rule catches own class properties marked as public.
132
127
133
- - [ ` @ stencil-community /prefer-vdom-listener` ] ( ./docs/prefer-vdom-listener.md )
128
+ - [ ` stencil/prefer-vdom-listener ` ] ( ./docs/prefer-vdom-listener.md )
134
129
135
130
This rule catches Stencil Listen with vdom events.
136
131
137
- - [ ` @ stencil-community /props-must-be-public` ] ( ./docs/props-must-be-public.md )
132
+ - [ ` stencil/props-must-be-public ` ] ( ./docs/props-must-be-public.md )
138
133
139
134
This rule catches Stencil Props marked as private or protected.
140
135
141
- - [ ` @ stencil-community /props-must-be-readonly` ] ( ./docs/props-must-be-readonly.md )
136
+ - [ ` stencil/props-must-be-readonly ` ] ( ./docs/props-must-be-readonly.md )
142
137
143
138
This rule catches Stencil Props marked as non readonly, excluding mutable ones.
144
139
145
- - [ ` @ stencil-community /render-returns-host` ] ( ./docs/render-returns-host.md )
140
+ - [ ` stencil/render-returns-host ` ] ( ./docs/render-returns-host.md )
146
141
147
142
This rule catches Stencil Render returning array instead of Host tag.
148
143
149
- - [ ` @ stencil-community /required-jsdoc` ] ( ./docs/required-jsdoc.md )
144
+ - [ ` stencil/required-jsdoc ` ] ( ./docs/required-jsdoc.md )
150
145
151
146
This rule catches Stencil Props, Methods and Events to define jsdoc.
152
147
153
- - [ ` @ stencil-community /required-prefix` ] ( ./docs/required-prefix.md )
148
+ - [ ` stencil/required-prefix ` ] ( ./docs/required-prefix.md )
154
149
155
150
This rule catches Stencil Component required tag name prefix.
156
151
157
- - [ ` @ stencil-community /reserved-member-names` ] ( ./docs/reserved-member-names.md )
152
+ - [ ` stencil/reserved-member-names ` ] ( ./docs/reserved-member-names.md )
158
153
159
154
This rule catches Stencil Prop names that share names of Global HTML Attributes.
160
155
161
- - [ ` @ stencil-community /single-export` ] ( ./docs/single-export.md )
156
+ - [ ` stencil/single-export ` ] ( ./docs/single-export.md )
162
157
163
158
This rule catches modules that expose more than just the Stencil Component itself.
164
159
165
- - [ ` @ stencil-community /strict-mutable` ] ( ./docs/strict-mutable.md )
160
+ - [ ` stencil/strict-mutable ` ] ( ./docs/strict-mutable.md )
166
161
167
162
This rule catches Stencil Prop marked as mutable but not changing value in code.
168
163
169
164
## Recommended rules
170
165
171
166
``` json
172
167
{
173
- "@ stencil-community /async-methods" : " error" ,
174
- "@ stencil-community /ban-prefix" : [" error" , [" stencil" , " stnl" , " st" ]],
175
- "@ stencil-community /decorators-context" : " error" ,
176
- "@ stencil-community /decorators-style" : [
168
+ "stencil/async-methods" : " error" ,
169
+ "stencil/ban-prefix" : [" error" , [" stencil" , " stnl" , " st" ]],
170
+ "stencil/decorators-context" : " error" ,
171
+ "stencil/decorators-style" : [
177
172
" error" , {
178
173
"prop" : " inline" ,
179
174
"state" : " inline" ,
@@ -183,20 +178,20 @@ This rule catches Stencil Prop marked as mutable but not changing value in code.
183
178
"watch" : " multiline" ,
184
179
"listen" : " multiline"
185
180
}],
186
- "@ stencil-community /element-type" : " error" ,
187
- "@ stencil-community /host-data-deprecated" : " error" ,
188
- "@ stencil-community /methods-must-be-public" : " error" ,
189
- "@ stencil-community /no-unused-watch" : " error" ,
190
- "@ stencil-community /own-methods-must-be-private" : " error" ,
191
- "@ stencil-community /own-props-must-be-private" : " error" ,
192
- "@ stencil-community /prefer-vdom-listener" : " error" ,
193
- "@ stencil-community /props-must-be-public" : " error" ,
194
- "@ stencil-community /props-must-be-readonly" : " error" ,
195
- "@ stencil-community /render-returns-host" : " error" ,
196
- "@ stencil-community /required-jsdoc" : " error" ,
197
- "@ stencil-community /reserved-member-names" : " error" ,
198
- "@ stencil-community /single-export" : " error" ,
199
- "@ stencil-community /strict-mutable" : " error"
181
+ "stencil/element-type" : " error" ,
182
+ "stencil/host-data-deprecated" : " error" ,
183
+ "stencil/methods-must-be-public" : " error" ,
184
+ "stencil/no-unused-watch" : " error" ,
185
+ "stencil/own-methods-must-be-private" : " error" ,
186
+ "stencil/own-props-must-be-private" : " error" ,
187
+ "stencil/prefer-vdom-listener" : " error" ,
188
+ "stencil/props-must-be-public" : " error" ,
189
+ "stencil/props-must-be-readonly" : " error" ,
190
+ "stencil/render-returns-host" : " error" ,
191
+ "stencil/required-jsdoc" : " error" ,
192
+ "stencil/reserved-member-names" : " error" ,
193
+ "stencil/single-export" : " error" ,
194
+ "stencil/strict-mutable" : " error"
200
195
}
201
196
```
202
197
@@ -211,4 +206,4 @@ All contributions welcome.
211
206
212
207
## License
213
208
214
- - [ MIT] ( https://raw.githubusercontent.com/stencil-community/stencil/ main/LICENSE )
209
+ - [ MIT] ( https://raw.githubusercontent.com/stenciljs/eslint-plugin/refs/heads/ main/LICENSE.md )
0 commit comments