pax_global_header 0000666 0000000 0000000 00000000064 14122172157 0014514 g ustar 00root root 0000000 0000000 52 comment=fe01699d1817b6d7bea80317361dd264bfa1d768 eslint-plugin-html-6.2.0/ 0000775 0000000 0000000 00000000000 14122172157 0015255 5 ustar 00root root 0000000 0000000 eslint-plugin-html-6.2.0/.editorconfig 0000664 0000000 0000000 00000000165 14122172157 0017734 0 ustar 00root root 0000000 0000000 root = true [*] charset = "utf-8" end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true eslint-plugin-html-6.2.0/.eslintignore 0000664 0000000 0000000 00000000013 14122172157 0017752 0 ustar 00root root 0000000 0000000 /coverage/ eslint-plugin-html-6.2.0/.eslintrc.yml 0000664 0000000 0000000 00000000335 14122172157 0017702 0 ustar 00root root 0000000 0000000 extends: benoitz-prettier rules: # trailingComma: es5 for node 4 support prettier/prettier: [ error, { trailingComma: es5, semi: false } ] env: node: true parserOptions: sourceType: script ecmaVersion: 2018 eslint-plugin-html-6.2.0/.github/ 0000775 0000000 0000000 00000000000 14122172157 0016615 5 ustar 00root root 0000000 0000000 eslint-plugin-html-6.2.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14122172157 0021000 5 ustar 00root root 0000000 0000000 eslint-plugin-html-6.2.0/.github/ISSUE_TEMPLATE/bug-report.md 0000664 0000000 0000000 00000001115 14122172157 0023406 0 ustar 00root root 0000000 0000000 --- name: Bug report about: Report a bug or a misbehaviour --- ## Description ## Setup configuration * ESLint version: * eslint-plugin-html version: * NodeJS version: * Operating System name and version: * ESLint configuration (.eslintrc): * Editor name and version: * Plugin name and version: ## Aditional context eslint-plugin-html-6.2.0/.github/ISSUE_TEMPLATE/feature_request.md 0000664 0000000 0000000 00000000670 14122172157 0024530 0 ustar 00root root 0000000 0000000 --- name: Feature request about: Suggest an idea for this project --- ## Description ## Alternatives ## Additional context eslint-plugin-html-6.2.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14122172157 0020652 5 ustar 00root root 0000000 0000000 eslint-plugin-html-6.2.0/.github/workflows/tests.yml 0000664 0000000 0000000 00000002007 14122172157 0022536 0 ustar 00root root 0000000 0000000 name: Tests on: push: schedule: # Every sunday at midnight - cron: '0 0 * * 0' jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: npm ci - run: npm run lint integration: runs-on: ubuntu-latest strategy: matrix: eslint: ["4.7", latest, next] steps: - uses: actions/checkout@v2 - run: npm ci - run: ESLINT_VERSION=${{ matrix.eslint }} ./tools/integration-tests.bash test: runs-on: ubuntu-latest strategy: matrix: include: - node: 10 eslint: latest - node: 12 eslint: latest - node: 14 eslint: "4.7" - node: 14 eslint: latest - node: 14 eslint: next steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - run: npm ci - run: npm install eslint@${{ matrix.eslint }} - run: npm test eslint-plugin-html-6.2.0/.gitignore 0000664 0000000 0000000 00000000032 14122172157 0017240 0 ustar 00root root 0000000 0000000 /node_modules/ /coverage/ eslint-plugin-html-6.2.0/.npmignore 0000664 0000000 0000000 00000000027 14122172157 0017253 0 ustar 00root root 0000000 0000000 * !src/* !CHANGELOG.md eslint-plugin-html-6.2.0/.prettierrc.yml 0000664 0000000 0000000 00000000037 14122172157 0020241 0 ustar 00root root 0000000 0000000 trailingComma: es5 semi: false eslint-plugin-html-6.2.0/CHANGELOG.md 0000664 0000000 0000000 00000010657 14122172157 0017077 0 ustar 00root root 0000000 0000000 2021-09-20 v6.2.0 * Update dependencies * Fix support for ESLint v8.0.0-beta.2 * Add .riot extension #146 2021-03-08 v6.1.2 * Update htmlparser2 #141 * Update dependencies 2020-11-11 v6.1.1 * Update dependencies * Move from travis to github actions 2020-09-06 v6.1.0 * Allow dots in extensions #127 2020-08-08 v6.0.3 * Update dependencies 2020-04-15 v6.0.2 * Remove npm-shrinkwrap.json from the npm package #125 2020-04-05 v6.0.1 (the 5th anniversary release) * Update dependencies * Run CI against eslint@next * Add eslint-plugin-php-markup reference to the README 2019-06-26 v6.0.0 (the 666 release) * **Breaking: drop Node 6 support** * Fix support for ESLint v6 2019-05-13 v5.0.5 * Fix support for ESLint v6.0.0-alpha.1 (again) * Improved integration tests 2019-05-12 v5.0.4 * Fix support for ESLint v6.0.0-alpha.1 #117 2019-02-02 v5.0.3 * Fix support for `parserOptions.ecmaFeatures.globalReturn: true` while sharing scope between multiple script tags 2019-02-02 v5.0.2 * Fix support for the --report-unused-disabled-directives option #111 2019-02-02 v5.0.1 * Fix compatibility with ESLint 5.13.0 * Update dependencies 2018-11-11 v5.0.0 * **Breaking: drop Node 4 support** * **Breaking: don't lint .vue files by default** * Update dependencies 2018-09-22 v4.0.6 * Ignore script tags with a `src` attribute #102 * More detailed error reporting 2018-06-20 v4.0.5 * Fix typo regression from v4.0.4 2018-06-20 v4.0.4 * Request detailed informations when ESLint is not found 2018-04-11 v4.0.3 * Prevent patching ESLint multiple times #89 2018-01-24 v4.0.2 * Fix compatibility with tslint #85 2017-11-22 v4.0.1 * Fix processing files after processing a HTML file without script tag #82 2017-11-12 v4.0.0 * **Breaking: drop ESLint < 4.7 support** * **Breaking: Non-module script tags are sharing the global scope** #66 * Lint script tags with `type="module"` by default 2017-09-16 v3.2.2 * Fix ESLint 4.7 support 2017-09-03 v3.2.1 * Fix ESLint 4.6 support #77 2017-08-12 v3.2.0 * improve compatibility with the `prettier` plugin by ignoring the first empty script line #76 * fix compatibility with the `eslint-comments` plugin #70 * add some *Troubleshooting* documentation about linting template markup and Vue files 2017-07-18 v3.1.1 * Fix node 4 support #71 #72 2017-07-11 v3.1.0 * Remap messages "source" property to fix custom formatters support #69 2017-06-12 v3.0.0 [migration guide](MIGRATION_TO_V3.md) * **Breaking: lint script tags separately** #49 #55 #56 * ESLint 4 support #57 * Support nested settings in a "html" object #58 2017-05-06 v2.0.3 * No change, new version to work around a publish issue 2017-05-06 v2.0.2 * Support self-closing script tags in XHTML #52 * Fix tests for ESLint 4.0.0-alpha.{0-2} 2017-02-16 v2.0.1 * Support for empty filenames #48 * Support for empty files #46 2017-01-25 v2.0.0 * **Breaking: drop `html/xml-mode` setting** * `eslint --fix` support #23 * Allow configuring HTML and XML extensions via ESLint config * Allow configuring JS MIME types via ESLint config * Report correct end locations of error messages * Report correct fix ranges of error messages 2016-11-18 v1.7.0 * Ignore all warnings for non-script lines #37 2016-11-05 v1.6.0 * Patch all loaded eslint packages #28 2016-10-23 v1.5.5 * Fix typo in handlebars extension #36 2016-10-22 v1.5.4 * Support `.nunjucks` files #35 2016-09-24 v1.5.3 * Fix tests for ESLint 3.6.0 #32 * Support `.we` files #30 2016-08-06 v1.5.2 * Laxer way to retrieve the eslint package #27 * Support `.erb` files #26 * Support `.tag` files #25 2016-05-22 v1.5.1 * Republish v1.5.0 on NPM, files were missing because of npm/npm#5082 2016-05-22 v1.5.0 * Support `.handlebars` files * Introduce the `html/xml-mode` setting and parse XML files as XML #20 * Support `.twig` files #21 * Support the `text/ecmascript-6` mime type #17 2016-02-16 v1.4.0 * Support `.php` files 2016-01-27 v1.3.0 * Fix crlf newlines support #16 * Introduce the `html/report-bad-indent` setting * Introduce the `html/indent` setting * Support more standard JS MIME types #15 2016-01-15 v1.2.0 * Support the `text/babel` mime type * Support `.mustache` files #11 2015-11-02 v1.1.0 * Stop non-JS lines breaking `no-multiple-empty-lines` #8 2015-08-22 v1.0.4 * Check if there is some lines before striping the last line spaces #7 2015-08-17 v1.0.3 * Support `.hbs` files 2015-06-30 v1.0.2 * Support `.vue` files #4 2015-04-18 v1.0.1 * Fix space eating issue * Introduce unit tests 2015-04-05 v1.0.0 * Add README * Initial commit eslint-plugin-html-6.2.0/LICENSE 0000664 0000000 0000000 00000001337 14122172157 0016266 0 ustar 00root root 0000000 0000000 Copyright (c) 2016, BenoƮt Zugmeyer Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. eslint-plugin-html-6.2.0/MIGRATION_TO_V3.md 0000664 0000000 0000000 00000006135 14122172157 0020107 0 ustar 00root root 0000000 0000000 Migrating to eslint-plugin-html v3 ================================== `eslint-plugin-html` v3 introduces a new way of linting inline script tags. Previously, all HTML parts of the file content were replaced by a `/* HTML */` comment. For example, if you had a file like this: ```html
``` it was first transformed to something like that before being processed by `ESLint`: ```javascript /* HTML */ console.log(1); /* HTML */ console.log(2); /* HTML */ ``` This caused many issues: * Error reported by `ESLint` outside of the JS code [were ignored](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/56), so rules reporting issues at the beginning of the file were ignored (like [`max-len`](http://eslint.org/docs/rules/max-len)) ; * When run in the browser, each inline script gets its own context. Two main issues come from this: * If you are using `"use strict"` in an inline script, the strict mode only applies in this script. Since the [`strict`](http://eslint.org/docs/rules/strict) rule with the `"global"` option is executed only once, [it only applies on the first inline script of the file](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/55) ; * Each [module scripts](https://html.spec.whatwg.org/#module-script) gets its own variable scope. So if you declare a variable directly in the body of a module, it won't be share to other inline script, contrary to traditional scripts who are executed in the global scope. By linting scripts together, the [`no-undef`](http://eslint.org/docs/rules/no-undef) rule will not warn if the variable is used in another script, and the [`no-redeclare`](http://eslint.org/docs/rules/no-redeclare) will prevent declaring the same variable in multiple module scripts. * Some other unexpected behaviors occured because of those `/* HTML */` comments, like [breaking eslint-disable-line](https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/49) in some condition. So, as of v3, `eslint-plugin-html` will lint inline scripts separately, meaning each script will be seen as a different file by `ESLint`. This implies backward incompatible changes for some rules, example: * [`max-len`](http://eslint.org/docs/rules/max-len) will report *scripts* with too much lines instead of the HTML file being too large ; * [`eol-last`](http://eslint.org/docs/rules/eol-last) will report missing or unnecessary new lines at the end of *sripts* instead of the HTML file (you probably don't want that!) ; * [`no-undef`](http://eslint.org/docs/rules/no-undef) will report undefined variables even if they are declared globally in another script (in this case you should use `/*global ...*/` to declare a variable as global). Please report issues you have with this new behavior. If some rules are causing too much trouble, I may add a setting to ignore messages coming from those in HTML files. You'll find other (non-breaking) changes in the [changelog](CHANGELOG.md). eslint-plugin-html-6.2.0/README.md 0000664 0000000 0000000 00000021504 14122172157 0016536 0 ustar 00root root 0000000 0000000 * [Usage](#usage) * [Multiple scripts tags in a HTML file](#multiple-scripts-tags-in-a-html-file) * [XML Support](#xml-support) * [Settings](#settings) * [`html/html-extensions`](#htmlhtml-extensions) * [`html/xml-extensions`](#htmlxml-extensions) * [`html/indent`](#htmlindent) * [`html/report-bad-indent`](#htmlreport-bad-indent) * [`html/javascript-mime-types`](#htmljavascript-mime-types) * [Troubleshooting](#troubleshooting) * [No file linted when running `eslint` on a directory](#no-file-linted-when-running-eslint-on-a-directory) * [Linting templates (or PHP)](#linting-templates-or-php) * [Linting Vue files](#linting-vue-files) * [Migration from older versions](#migration-from-older-versions) * [Credits](#credits) ## Usage Simply install via `npm install --save-dev eslint-plugin-html` and add the plugin to your ESLint configuration. See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#configuring-plugins). Example: ```javascript { "plugins": [ "html" ] } ``` ## 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: ` ``` 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 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 makes sure global variables are declared and used correctly in the non-module case. ## XML support This plugin parses HTML and XML markup slightly differently, mainly when considering `CDATA` sections: - in XML, any data inside a `CDATA` section will be considered as raw text (not XML) and the `CDATA` delimiter will be droped ; - in HTML, there is no such thing for ` ``` ### Linting VUE files Initially, [`eslint-plugin-vue`](https://github.com/vuejs/eslint-plugin-vue) was using `eslint-plugin-html` to lint code inside script tags. Since v3, `eslint-plugin-vue` is using its own parser, so it is _incompatible_ with `eslint-plugin-html`. You should use `eslint-plugin-vue` exclusively and remove `eslint-plugin-html` from your dependencies if you still have it. ## Migration from older versions ### 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 choose how [scopes are shared between script tags in the same HTML file](#multiple-scripts-tags-in-a-html-file). ### To v3 If you are considering upgrading to v3, please read [this guide](MIGRATION_TO_V3.md). ## Credits A big thank you to [@Bkucera](https://github.com/Bkucera) for the logo image! eslint-plugin-html-6.2.0/jest.config.js 0000664 0000000 0000000 00000000254 14122172157 0020025 0 ustar 00root root 0000000 0000000 "use strict" module.exports = { moduleNameMapper: { "@eslint/eslintrc/universal": "