Skip to content

Commit f7e7fcc

Browse files
authoredJul 18, 2022
Merge pull request #197 from BenoitZugmeyer/update-eslint-prettier
ci: update eslint config
2 parents e6d0e43 + ae0a8f8 commit f7e7fcc

13 files changed

+747
-284
lines changed
 

‎.eslintrc.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
extends: ["eslint:recommended", "prettier"],
3+
4+
rules: {
5+
"no-constant-condition": "off",
6+
"no-unused-vars": [
7+
"error",
8+
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_" },
9+
],
10+
},
11+
12+
env: {
13+
node: true,
14+
es2018: true,
15+
},
16+
}

‎.eslintrc.yml

-13
This file was deleted.

‎.github/ISSUE_TEMPLATE/bug-report.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Bug report
33
about: Report a bug or a misbehaviour
4-
54
---
65

76
## Description
@@ -12,17 +11,18 @@ Describe the issue precisely: what are you trying to do? what's the expected res
1211

1312
## Setup configuration
1413

15-
* ESLint version:
16-
* eslint-plugin-html version:
17-
* NodeJS version:
18-
* Operating System name and version:
19-
* ESLint configuration (.eslintrc):
14+
- ESLint version:
15+
- eslint-plugin-html version:
16+
- NodeJS version:
17+
- Operating System name and version:
18+
- ESLint configuration (.eslintrc):
2019

2120
<!--
2221
If run from an editor plugin:
2322
-->
24-
* Editor name and version:
25-
* Plugin name and version:
23+
24+
- Editor name and version:
25+
- Plugin name and version:
2626

2727
## Aditional context
2828

‎.github/ISSUE_TEMPLATE/feature_request.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
54
---
65

76
## Description

‎.github/dependabot.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
version: 2
22
updates:
3-
- package-ecosystem: npm
4-
directory: "/"
5-
schedule:
6-
interval: weekly
7-
open-pull-requests-limit: 99
8-
- package-ecosystem: github-actions
9-
directory: "/"
10-
schedule:
11-
interval: daily
12-
open-pull-requests-limit: 99
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 99
8+
- package-ecosystem: github-actions
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
open-pull-requests-limit: 99

‎.github/workflows/tests.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88
schedule:
99
# Every sunday at midnight
10-
- cron: '0 0 * * 0'
10+
- cron: "0 0 * * 0"
1111

1212
jobs:
1313
lint:
@@ -19,6 +19,8 @@ jobs:
1919
cache: npm
2020
- run: npm ci
2121
- run: npm run lint
22+
- run: npm run format
23+
- run: npx markdown-link-check -p README.md
2224

2325
integration:
2426
runs-on: ${{ matrix.os }}
@@ -39,10 +41,10 @@ jobs:
3941
# https://github.com/actions/setup-node/issues/515#issuecomment-1153685437
4042
- if: ${{ matrix.os == 'windows-latest' }}
4143
run: |
42-
$WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
43-
$NodeDirPath = Split-Path $WhereNode -Parent
44-
cd $NodeDirPath
45-
npm install npm@8.12.1
44+
$WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
45+
$NodeDirPath = Split-Path $WhereNode -Parent
46+
cd $NodeDirPath
47+
npm install npm@8.12.1
4648
- run: npm ci
4749
- run: bash tools/integration-tests.bash ${{ matrix.eslint }}
4850

‎.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/src/__tests__/fixtures

‎CHANGELOG.md

+135-86
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,232 @@
11
UNRELEASED v7.0.0
2-
* **Breaking: drop Node 10 support**
2+
3+
- **Breaking: drop Node 10 support**
34

45
2021-09-20 v6.2.0
5-
* Update dependencies
6-
* Fix support for ESLint v8.0.0-beta.2
7-
* Add .riot extension #146
6+
7+
- Update dependencies
8+
- Fix support for ESLint v8.0.0-beta.2
9+
- Add .riot extension #146
810

911
2021-03-08 v6.1.2
10-
* Update htmlparser2 #141
11-
* Update dependencies
12+
13+
- Update htmlparser2 #141
14+
- Update dependencies
1215

1316
2020-11-11 v6.1.1
14-
* Update dependencies
15-
* Move from travis to github actions
17+
18+
- Update dependencies
19+
- Move from travis to github actions
1620

1721
2020-09-06 v6.1.0
18-
* Allow dots in extensions #127
22+
23+
- Allow dots in extensions #127
1924

2025
2020-08-08 v6.0.3
21-
* Update dependencies
26+
27+
- Update dependencies
2228

2329
2020-04-15 v6.0.2
24-
* Remove npm-shrinkwrap.json from the npm package #125
30+
31+
- Remove npm-shrinkwrap.json from the npm package #125
2532

2633
2020-04-05 v6.0.1 (the 5th anniversary release)
27-
* Update dependencies
28-
* Run CI against eslint@next
29-
* Add eslint-plugin-php-markup reference to the README
34+
35+
- Update dependencies
36+
- Run CI against eslint@next
37+
- Add eslint-plugin-php-markup reference to the README
3038

3139
2019-06-26 v6.0.0 (the 666 release)
32-
* **Breaking: drop Node 6 support**
33-
* Fix support for ESLint v6
40+
41+
- **Breaking: drop Node 6 support**
42+
- Fix support for ESLint v6
3443

3544
2019-05-13 v5.0.5
36-
* Fix support for ESLint v6.0.0-alpha.1 (again)
37-
* Improved integration tests
45+
46+
- Fix support for ESLint v6.0.0-alpha.1 (again)
47+
- Improved integration tests
3848

3949
2019-05-12 v5.0.4
40-
* Fix support for ESLint v6.0.0-alpha.1 #117
50+
51+
- Fix support for ESLint v6.0.0-alpha.1 #117
4152

4253
2019-02-02 v5.0.3
43-
* Fix support for `parserOptions.ecmaFeatures.globalReturn: true` while sharing scope between multiple script tags
54+
55+
- Fix support for `parserOptions.ecmaFeatures.globalReturn: true` while sharing scope between multiple script tags
4456

4557
2019-02-02 v5.0.2
46-
* Fix support for the --report-unused-disabled-directives option #111
58+
59+
- Fix support for the --report-unused-disabled-directives option #111
4760

4861
2019-02-02 v5.0.1
49-
* Fix compatibility with ESLint 5.13.0
50-
* Update dependencies
62+
63+
- Fix compatibility with ESLint 5.13.0
64+
- Update dependencies
5165

5266
2018-11-11 v5.0.0
53-
* **Breaking: drop Node 4 support**
54-
* **Breaking: don't lint .vue files by default**
55-
* Update dependencies
67+
68+
- **Breaking: drop Node 4 support**
69+
- **Breaking: don't lint .vue files by default**
70+
- Update dependencies
5671

5772
2018-09-22 v4.0.6
58-
* Ignore script tags with a `src` attribute #102
59-
* More detailed error reporting
73+
74+
- Ignore script tags with a `src` attribute #102
75+
- More detailed error reporting
6076

6177
2018-06-20 v4.0.5
62-
* Fix typo regression from v4.0.4
78+
79+
- Fix typo regression from v4.0.4
6380

6481
2018-06-20 v4.0.4
65-
* Request detailed informations when ESLint is not found
82+
83+
- Request detailed informations when ESLint is not found
6684

6785
2018-04-11 v4.0.3
68-
* Prevent patching ESLint multiple times #89
86+
87+
- Prevent patching ESLint multiple times #89
6988

7089
2018-01-24 v4.0.2
71-
* Fix compatibility with tslint #85
90+
91+
- Fix compatibility with tslint #85
7292

7393
2017-11-22 v4.0.1
74-
* Fix processing files after processing a HTML file without script tag #82
94+
95+
- Fix processing files after processing a HTML file without script tag #82
7596

7697
2017-11-12 v4.0.0
77-
* **Breaking: drop ESLint < 4.7 support**
78-
* **Breaking: Non-module script tags are sharing the global scope** #66
79-
* Lint script tags with `type="module"` by default
98+
99+
- **Breaking: drop ESLint < 4.7 support**
100+
- **Breaking: Non-module script tags are sharing the global scope** #66
101+
- Lint script tags with `type="module"` by default
80102

81103
2017-09-16 v3.2.2
82-
* Fix ESLint 4.7 support
104+
105+
- Fix ESLint 4.7 support
83106

84107
2017-09-03 v3.2.1
85-
* Fix ESLint 4.6 support #77
108+
109+
- Fix ESLint 4.6 support #77
86110

87111
2017-08-12 v3.2.0
88-
* improve compatibility with the `prettier` plugin by ignoring the first empty script line #76
89-
* fix compatibility with the `eslint-comments` plugin #70
90-
* add some *Troubleshooting* documentation about linting template markup and Vue files
112+
113+
- improve compatibility with the `prettier` plugin by ignoring the first empty script line #76
114+
- fix compatibility with the `eslint-comments` plugin #70
115+
- add some _Troubleshooting_ documentation about linting template markup and Vue files
91116

92117
2017-07-18 v3.1.1
93-
* Fix node 4 support #71 #72
118+
119+
- Fix node 4 support #71 #72
94120

95121
2017-07-11 v3.1.0
96-
* Remap messages "source" property to fix custom formatters support #69
122+
123+
- Remap messages "source" property to fix custom formatters support #69
97124

98125
2017-06-12 v3.0.0 [migration guide](MIGRATION_TO_V3.md)
99-
* **Breaking: lint script tags separately** #49 #55 #56
100-
* ESLint 4 support #57
101-
* Support nested settings in a "html" object #58
126+
127+
- **Breaking: lint script tags separately** #49 #55 #56
128+
- ESLint 4 support #57
129+
- Support nested settings in a "html" object #58
102130

103131
2017-05-06 v2.0.3
104-
* No change, new version to work around a publish issue
132+
133+
- No change, new version to work around a publish issue
105134

106135
2017-05-06 v2.0.2
107-
* Support self-closing script tags in XHTML #52
108-
* Fix tests for ESLint 4.0.0-alpha.{0-2}
136+
137+
- Support self-closing script tags in XHTML #52
138+
- Fix tests for ESLint 4.0.0-alpha.{0-2}
109139

110140
2017-02-16 v2.0.1
111-
* Support for empty filenames #48
112-
* Support for empty files #46
141+
142+
- Support for empty filenames #48
143+
- Support for empty files #46
113144

114145
2017-01-25 v2.0.0
115-
* **Breaking: drop `html/xml-mode` setting**
116-
* `eslint --fix` support #23
117-
* Allow configuring HTML and XML extensions via ESLint config
118-
* Allow configuring JS MIME types via ESLint config
119-
* Report correct end locations of error messages
120-
* Report correct fix ranges of error messages
146+
147+
- **Breaking: drop `html/xml-mode` setting**
148+
- `eslint --fix` support #23
149+
- Allow configuring HTML and XML extensions via ESLint config
150+
- Allow configuring JS MIME types via ESLint config
151+
- Report correct end locations of error messages
152+
- Report correct fix ranges of error messages
121153

122154
2016-11-18 v1.7.0
123-
* Ignore all warnings for non-script lines #37
155+
156+
- Ignore all warnings for non-script lines #37
124157

125158
2016-11-05 v1.6.0
126-
* Patch all loaded eslint packages #28
159+
160+
- Patch all loaded eslint packages #28
127161

128162
2016-10-23 v1.5.5
129-
* Fix typo in handlebars extension #36
163+
164+
- Fix typo in handlebars extension #36
130165

131166
2016-10-22 v1.5.4
132-
* Support `.nunjucks` files #35
167+
168+
- Support `.nunjucks` files #35
133169

134170
2016-09-24 v1.5.3
135-
* Fix tests for ESLint 3.6.0 #32
136-
* Support `.we` files #30
171+
172+
- Fix tests for ESLint 3.6.0 #32
173+
- Support `.we` files #30
137174

138175
2016-08-06 v1.5.2
139-
* Laxer way to retrieve the eslint package #27
140-
* Support `.erb` files #26
141-
* Support `.tag` files #25
176+
177+
- Laxer way to retrieve the eslint package #27
178+
- Support `.erb` files #26
179+
- Support `.tag` files #25
142180

143181
2016-05-22 v1.5.1
144-
* Republish v1.5.0 on NPM, files were missing because of npm/npm#5082
182+
183+
- Republish v1.5.0 on NPM, files were missing because of npm/npm#5082
145184

146185
2016-05-22 v1.5.0
147-
* Support `.handlebars` files
148-
* Introduce the `html/xml-mode` setting and parse XML files as XML #20
149-
* Support `.twig` files #21
150-
* Support the `text/ecmascript-6` mime type #17
186+
187+
- Support `.handlebars` files
188+
- Introduce the `html/xml-mode` setting and parse XML files as XML #20
189+
- Support `.twig` files #21
190+
- Support the `text/ecmascript-6` mime type #17
151191

152192
2016-02-16 v1.4.0
153-
* Support `.php` files
193+
194+
- Support `.php` files
154195

155196
2016-01-27 v1.3.0
156-
* Fix crlf newlines support #16
157-
* Introduce the `html/report-bad-indent` setting
158-
* Introduce the `html/indent` setting
159-
* Support more standard JS MIME types #15
197+
198+
- Fix crlf newlines support #16
199+
- Introduce the `html/report-bad-indent` setting
200+
- Introduce the `html/indent` setting
201+
- Support more standard JS MIME types #15
160202

161203
2016-01-15 v1.2.0
162-
* Support the `text/babel` mime type
163-
* Support `.mustache` files #11
204+
205+
- Support the `text/babel` mime type
206+
- Support `.mustache` files #11
164207

165208
2015-11-02 v1.1.0
166-
* Stop non-JS lines breaking `no-multiple-empty-lines` #8
209+
210+
- Stop non-JS lines breaking `no-multiple-empty-lines` #8
167211

168212
2015-08-22 v1.0.4
169-
* Check if there is some lines before striping the last line spaces #7
213+
214+
- Check if there is some lines before striping the last line spaces #7
170215

171216
2015-08-17 v1.0.3
172-
* Support `.hbs` files
217+
218+
- Support `.hbs` files
173219

174220
2015-06-30 v1.0.2
175-
* Support `.vue` files #4
221+
222+
- Support `.vue` files #4
176223

177224
2015-04-18 v1.0.1
178-
* Fix space eating issue
179-
* Introduce unit tests
225+
226+
- Fix space eating issue
227+
- Introduce unit tests
180228

181229
2015-04-05 v1.0.0
182-
* Add README
183-
* Initial commit
230+
231+
- Add README
232+
- Initial commit

‎MIGRATION_TO_V3.md

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,74 @@
1-
Migrating to eslint-plugin-html v3
2-
==================================
1+
# Migrating to eslint-plugin-html v3
32

4-
`eslint-plugin-html` v3 introduces a new way of linting inline script tags. Previously, all HTML
5-
parts of the file content were replaced by a `/* HTML */` comment. For example, if you had a file
3+
`eslint-plugin-html` v3 introduces a new way of linting inline script tags. Previously, all HTML
4+
parts of the file content were replaced by a `/* HTML */` comment. For example, if you had a file
65
like this:
76

87
```html
98
<!DOCTYPE html>
109
<html>
1110
<body>
1211
<script>
13-
console.log(1);
12+
console.log(1)
1413
</script>
1514
<script>
16-
console.log(2);
15+
console.log(2)
1716
</script>
1817
</body>
1918
</html>
2019
```
20+
2121
it was first transformed to something like that before being processed by `ESLint`:
22+
2223
```javascript
2324
/* HTML */
24-
console.log(1);
25+
console.log(1)
2526
/* HTML */
26-
console.log(2);
27+
console.log(2)
2728
/* HTML */
2829
```
2930

3031
This caused many issues:
3132

32-
* Error reported by `ESLint` outside of the JS code [were
33+
- Error reported by `ESLint` outside of the JS code [were
3334
ignored](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/56), so rules reporting
3435
issues at the beginning of the file were ignored (like
3536
[`max-len`](http://eslint.org/docs/rules/max-len))&nbsp;;
3637

37-
* When run in the browser, each inline script gets its own context. Two main issues come from this:
38+
- When run in the browser, each inline script gets its own context. Two main issues come from this:
3839

39-
* If you are using `"use strict"` in an inline script, the strict mode only applies in this
40+
- If you are using `"use strict"` in an inline script, the strict mode only applies in this
4041
script. Since the [`strict`](http://eslint.org/docs/rules/strict) rule with the `"global"`
4142
option is executed only once, [it only applies on the first inline script of the
4243
file](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/55)&nbsp;;
4344

44-
* Each [module scripts](https://html.spec.whatwg.org/#module-script) gets its own variable scope.
45+
- Each [module scripts](https://html.spec.whatwg.org/#module-script) gets its own variable scope.
4546
So if you declare a variable directly in the body of a module, it won't be share to other
4647
inline script, contrary to traditional scripts who are executed in the global scope. By linting
4748
scripts together, the [`no-undef`](http://eslint.org/docs/rules/no-undef) rule will not warn if
4849
the variable is used in another script, and the
4950
[`no-redeclare`](http://eslint.org/docs/rules/no-redeclare) will prevent declaring the same
5051
variable in multiple module scripts.
5152

52-
* Some other unexpected behaviors occured because of those `/* HTML */` comments, like [breaking
53+
- Some other unexpected behaviors occured because of those `/* HTML */` comments, like [breaking
5354
eslint-disable-line](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/49) in some
5455
condition.
5556

5657
So, as of v3, `eslint-plugin-html` will lint inline scripts separately, meaning each script
57-
will be seen as a different file by `ESLint`. This implies backward incompatible changes for some
58+
will be seen as a different file by `ESLint`. This implies backward incompatible changes for some
5859
rules, example:
5960

60-
* [`max-len`](http://eslint.org/docs/rules/max-len) will report *scripts* with too much lines
61+
- [`max-len`](http://eslint.org/docs/rules/max-len) will report _scripts_ with too much lines
6162
instead of the HTML file being too large&nbsp;;
6263

63-
* [`eol-last`](http://eslint.org/docs/rules/eol-last) will report missing or unnecessary new lines
64-
at the end of *sripts* instead of the HTML file (you probably don't want that!)&nbsp;;
64+
- [`eol-last`](http://eslint.org/docs/rules/eol-last) will report missing or unnecessary new lines
65+
at the end of _sripts_ instead of the HTML file (you probably don't want that!)&nbsp;;
6566

66-
* [`no-undef`](http://eslint.org/docs/rules/no-undef) will report undefined variables even if they
67+
- [`no-undef`](http://eslint.org/docs/rules/no-undef) will report undefined variables even if they
6768
are declared globally in another script (in this case you should use `/*global ...*/` to declare a
6869
variable as global).
6970

70-
Please report issues you have with this new behavior. If some rules are causing too much trouble, I
71+
Please report issues you have with this new behavior. If some rules are causing too much trouble, I
7172
may add a setting to ignore messages coming from those in HTML files.
7273

7374
You'll find other (non-breaking) changes in the [changelog](CHANGELOG.md).

‎README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ To illustrate this behavior, consider this HTML extract:
6666

6767
```html
6868
<script>
69-
var foo = 1;
69+
var foo = 1
7070
</script>
7171

7272
<script>
73-
alert(foo);
73+
alert(foo)
7474
</script>
7575
```
7676

@@ -205,7 +205,6 @@ will have to specify extra extensions with the `--ext` option. Example: `eslint
205205
will lint both `.html` and `.js` files in the `src` directory. See [ESLint
206206
documentation](http://eslint.org/docs/user-guide/command-line-interface#ext).
207207

208-
209208
### Linting templates (or PHP)
210209

211210
`eslint-plugin-html` won't evaluate or remove your template markup. If you have template markup in
@@ -221,9 +220,9 @@ line, so it will be written below the comment. PHP example:
221220

222221
```html
223222
<script>
224-
var mydata;
223+
var mydata
225224
// <?= "\n mydata = " . json_encode($var) . ";" ?>
226-
console.log(mydata);
225+
console.log(mydata)
227226
</script>
228227
```
229228

@@ -253,4 +252,4 @@ If you are considering upgrading to v3, please read [this guide](MIGRATION_TO_V3
253252

254253
## Credits
255254

256-
A big thank you to [@Bkucera](https://github.com/Bkucera) for the logo image!
255+
A big thank you to [@kuceb](https://github.com/kuceb) for the logo image!

‎package-lock.json

+535-127
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121
},
2222
"devDependencies": {
2323
"eslint": "^8.5.0",
24-
"eslint-config-benoitz-prettier": "^1.1.0",
24+
"eslint-config-prettier": "^8.5.0",
2525
"jest": "^28.1.3",
26+
"markdown-link-check": "^3.10.2",
2627
"prettier": "^2.1.2",
2728
"semver": "^7.3.2"
2829
},
2930
"scripts": {
3031
"validate": "npm run lint && npm run test",
3132
"test": "jest",
32-
"lint": "eslint ."
33+
"lint": "eslint .",
34+
"format": "prettier --check ."
3335
}
3436
}

‎tools/scope-sharing-browser-tests.html

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
try {
1111
if (fn() === false) console.error(`${fn} returned false`)
1212
console.log(`${fn} succeeded`)
13-
}
14-
catch (e) {
13+
} catch (e) {
1514
console.error(`${fn} threw ${e}`)
1615
}
1716
}
@@ -20,12 +19,10 @@
2019
try {
2120
fn()
2221
console.error(`${fn} didn't threw ${expectedException.name}`)
23-
}
24-
catch (e) {
22+
} catch (e) {
2523
if (e instanceof expectedException) {
2624
console.log(`${fn} expectedly threw ${expectedException.name}`)
27-
}
28-
else {
25+
} else {
2926
console.log(`${fn} threw ${e} instead of ${expectedException.name}`)
3027
}
3128
}
@@ -76,7 +73,9 @@
7673
</script>
7774

7875
<script>
79-
console.group("Modules are not exporting declarations to the global scope")
76+
console.group(
77+
"Modules are not exporting declarations to the global scope"
78+
)
8079
expectThrows(() => varModuleDeclared, ReferenceError)
8180
console.groupEnd()
8281
</script>

0 commit comments

Comments
 (0)
Please sign in to comment.