Socket
Socket
Sign inDemoInstall

eslint-plugin-html

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-html - npm Package Compare versions

Comparing version 4.0.0-alpha.1 to 4.0.0

4

CHANGELOG.md

@@ -1,4 +0,4 @@

2017-10-08 v4.0.0-alpha.0
2017-11-12 v4.0.0
* **Breaking: drop ESLint < 4.7 support**
* Non-module script tags are sharing the global scope #66
* **Breaking: Non-module script tags are sharing the global scope** #66
* Lint script tags with `type="module"` by default

@@ -5,0 +5,0 @@

{
"name": "eslint-plugin-html",
"version": "4.0.0-alpha.1",
"version": "4.0.0",
"description": "A ESLint plugin to lint and fix inline scripts contained in HTML files.",

@@ -5,0 +5,0 @@ "license": "ISC",

eslint-plugin-html
==================
[![NPM version](https://img.shields.io/npm/v/eslint-plugin-html.svg)](https://www.npmjs.com/package/eslint-plugin-html)
[![Build Status](https://travis-ci.org/BenoitZugmeyer/eslint-plugin-html.svg?branch=master)](https://travis-ci.org/BenoitZugmeyer/eslint-plugin-html)
This [`ESLint`](http://eslint.org) plugin allows linting and fixing inline scripts contained in HTML
files.
Migration to v4
---------------
`eslint-plugin-html` v4 requires at least ESLint v4.7. This is because a lot of internal changes
occured in ESLint v4.7, including a [new API to support autofixing in
preprocessors](https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins).
If you are still using an older version of ESLint, please consider upgrading, or keep using
`eslint-plugin-html` v3.
The big feature (and breaking change) in `eslint-plugin-html` v4 is the ability to chose how [scopes
are shared between script tags in the same HTML file](#multiple-scripts-tags-in-a-html-file).
Migration to v3

@@ -36,2 +51,47 @@ ---------------

Multiple scripts tags in a HTML file
------------------------------------
When linting a HTML with multiple script tags, this plugin tries to emulate the browser behavior by
sharing the global scope between scripts by default. This behavior doesn't apply to "module"
scripts (ie: `<script type="module">` and most transpiled code), where [each script tag gets its own
top-level scope](http://exploringjs.com/es6/ch_modules.html#_modules).
ESLint has already [an
option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) to tell the parser
if the script are modules. `eslint-plugin-html` will use this option as well to know if the scopes
should be shared (the default) or not. To change this, just set it in your ESLint configuration:
```
{
"parserOptions": {
"sourceType": "module"
}
}
```
To illustrate this behavior, consider this HTML extract:
```html
<script>
var foo = 1;
</script>
<script>
alert(foo);
</script>
```
This is perfectly valid by default, and the ESLint rules `no-unused-vars` and `no-undef` shouldn't
complain. But if those scripts are considerated as ES modules, `no-unused-vars` should report an
error in the first script, and `no-undef` should report an error in the second script.
### History
In `eslint-plugin-html` v1 and v2, script code were concatenated and a linted in a single pass, so
the scope were always shared. This caused [some issues](MIGRATION_TO_V3.md), so in v3, all scripts
were linted separately, and scopes were never shared. In v4, the plugin still lint scripts
separately, but make sure global variables are declared and used correctly in the non-module case.
XML support

@@ -38,0 +98,0 @@ -----------

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc