You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add another processor for HTML files (usage with html-eslint)
* Add npm link tip to dev guide
* Add tip for npm ls command
* Rename processor to make distinguishable between object and string
* Fix wrong import
* Add command to remove npm link
* Update Readme with new HTML config
* Improve wording of docstring
* Reflect new processor name in legacy format
* Move HTML section down & give broader context
* Clarify where to add the `ignores` if wanted
Copy file name to clipboardExpand all lines: DEV.md
+21-3Lines changed: 21 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,44 @@
1
1
# Some developer guidelines
2
2
3
+
## Install as npm package locally to test
4
+
5
+
Also see [this answer](https://stackoverflow.com/a/28392481/9655481). Basically, inside another project where you want to test the plugin, you can install it as an npm package via a local path:
6
+
7
+
```bash
8
+
npm link /path/to/eslint-plugin-erb
9
+
```
10
+
11
+
Other useful commands:
12
+
13
+
```bash
14
+
npm ls --global
15
+
```
16
+
17
+
Finally to remove the link:
18
+
19
+
```bash
20
+
npm unlink eslint-plugin-erb
21
+
```
3
22
4
23
## Merge strategies
5
24
6
25
- Feature branches to `dev`: squash commit
7
26
- Continuous Release from `dev` to `main`: standard merge commit
8
27
- Hotfixes: branch off `main`, merge PR into `main` via squash commit, then merge back `main` to `dev` via standard merge commit.
9
28
10
-
11
29
## Create a new release (and publish to npm)
12
30
13
31
As this is only a small project, we haven't automated publishing to the NPM registry yet and instead rely on the following manual workflow.
14
32
15
33
- Make sure the tests pass locally: `npm test` ✔
16
34
- Make another commit on the `dev` branch bumping the npm version in the `package.json`. For that, use:
35
+
17
36
```sh
18
37
npm run bump-version -- [<newversion>| major | minor | patch]
19
38
```
39
+
20
40
- ⚠ Copy the version specifier from `package.json` into the `index.js` meta information object.
21
41
- Once the `dev` branch is ready, open a PR (Pull request) called "Continuous Release <version.number>" and give it the "release" label. Merge this PR into `main`.
22
42
- Create a new release via the GitHub UI and assign a new tag alongside that.
23
43
- Fetch the tag locally (`git fetch`) and publish to npm via `npm run publish-final`. You probably have to login to npm first (`npm login`).
24
44
- Enjoy ✌ Check that the release is available [here on npm](https://www.npmjs.com/package/eslint-plugin-erb).
> v2.0.0 is breaking. We use the new ESLint flat config format. Use `erb:recommended-legacy` if you want to keep using the old `.eslintrc.js` format.
11
11
@@ -19,19 +19,15 @@ Install the plugin alongside [ESLint](https://eslint.org/docs/latest/use/getting
19
19
npm install --save-dev eslint eslint-plugin-erb
20
20
```
21
21
22
-
23
22
### Configure
24
23
25
-
Starting of v9 ESLint provides a [new flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`). Also see the [configuration migration guide](https://eslint.org/docs/latest/use/configure/migration-guide). Use it as follows and it will automatically lint all your `.js.erb` files:
24
+
Starting of v9 ESLint provides a [new flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`). Also see the [configuration migration guide](https://eslint.org/docs/latest/use/configure/migration-guide). Use it as follows and it will automatically lint all your **JavaScript code** in `.js.erb` files:
26
25
27
26
```js
28
27
// eslint.config.js
29
28
importerbfrom"eslint-plugin-erb";
30
29
31
30
exportdefault [
32
-
// if you are using VSCode, don't forget to put
33
-
// "eslint.experimental.useFlatConfig": true
34
-
// in your settings.json
35
31
erb.configs.recommended,
36
32
{
37
33
linterOptions: {
@@ -46,7 +42,6 @@ export default [
46
42
// your other configuration options
47
43
}
48
44
];
49
-
50
45
```
51
46
52
47
<details>
@@ -120,25 +115,20 @@ export default [
120
115
121
116
</details>
122
117
123
-
124
118
<details>
125
119
126
120
<summary>Alternative way to configure the processor</summary>
127
121
128
122
With this variant you have a bit more control over what is going on, e.g. you could name your files `.js.special-erb` and still lint them (if they contain JS and ERB syntax).
129
123
130
-
131
124
```js
132
125
// eslint.config.js
133
126
importerbfrom"eslint-plugin-erb";
134
127
135
128
exportdefault [
136
-
// if you are using VSCode, don't forget to put
137
-
// "eslint.experimental.useFlatConfig": true
138
-
// in your settings.json
139
129
{
140
130
files: ["**/*.js.erb"],
141
-
processor:erb.processors.erbProcessor,
131
+
processor:erb.processors.processorJs,
142
132
},
143
133
{
144
134
linterOptions: {
@@ -157,10 +147,6 @@ export default [
157
147
158
148
</details>
159
149
160
-
161
-
162
-
163
-
164
150
<details>
165
151
<summary>Legacy: you can still use the old `.eslintrc.js` format</summary>
166
152
@@ -173,7 +159,7 @@ module.exports = {
173
159
};
174
160
```
175
161
176
-
Or you can configure the processor manually (advanced):
162
+
Or you can configure the processor manually:
177
163
178
164
```js
179
165
// .eslintrc.js
@@ -182,23 +168,47 @@ module.exports = {
182
168
overrides: [
183
169
{
184
170
files: ["**/*.js.erb"],
185
-
processor:"erb/erbProcessor"
171
+
processor:"erb/processorJs"
186
172
}
187
173
]
188
174
};
189
175
```
190
176
191
177
</details>
192
178
179
+
If you also want to lint **HTML code** in `.html.erb` files, you can use our preprocessor in conjunction with the amazing [`html-eslint`](https://html-eslint.org/) plugin. Install `html-eslint`, then add the following to your ESLint config file (flat config format):
193
180
181
+
```js
182
+
// eslint.config.js
183
+
importerbfrom"eslint-plugin-erb";
194
184
185
+
exportdefault [
186
+
// your other configurations...
187
+
{
188
+
processor:erb.processors["processorHtml"],
189
+
...html.configs["flat/recommended"],
190
+
files: ["**/*.html", "**/*.html.erb"],
191
+
rules: {
192
+
...html.configs["flat/recommended"].rules,
193
+
"@html-eslint/indent": ["error", 2],
194
+
// other rules...
195
+
},
196
+
}
197
+
];
198
+
```
195
199
200
+
Additionally, you might want to add the following option to the other objects (`{}`) in `export default []` (at the same level like the `files` key above), since other rules might be incompatible with HTML files:
201
+
202
+
```js
203
+
ignores: ["**/*.html**"],
204
+
```
196
205
197
206
## Editor Integrations
198
207
199
208
The [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) for VSCode has built-in support for the ERB processor once you've configured it in your `.eslintrc.js` file as shown above.
200
209
201
210
If you're using VSCode, you may find this `settings.json` options useful:
211
+
202
212
```jsonc
203
213
{
204
214
"editor.formatOnSave":false, // it still autosaves with the options below
@@ -208,7 +218,6 @@ If you're using VSCode, you may find this `settings.json` options useful:
0 commit comments