diff -Nru node-eslint-plugin-html-5.0.5/CHANGELOG.md node-eslint-plugin-html-6.1.1/CHANGELOG.md --- node-eslint-plugin-html-5.0.5/CHANGELOG.md 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/CHANGELOG.md 2020-11-11 14:19:27.000000000 +0000 @@ -1,3 +1,25 @@ +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 @@ -16,7 +38,7 @@ * Update dependencies 2018-11-11 v5.0.0 -* **Breaking: drop support of Node.js 4** +* **Breaking: drop Node 4 support** * **Breaking: don't lint .vue files by default** * Update dependencies diff -Nru node-eslint-plugin-html-5.0.5/debian/changelog node-eslint-plugin-html-6.1.1/debian/changelog --- node-eslint-plugin-html-5.0.5/debian/changelog 2020-06-06 09:29:23.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/changelog 2020-12-17 03:29:37.000000000 +0000 @@ -1,3 +1,48 @@ +node-eslint-plugin-html (6.1.1-1) unstable; urgency=medium + + [ upstream ] + * nre release(s) + + [ Jonas Smedegaard ] + * update patch 2001 + * update lint-check to use newer EcmaScript version + + -- Jonas Smedegaard Thu, 17 Dec 2020 04:29:37 +0100 + +node-eslint-plugin-html (5.0.5-2) unstable; urgency=medium + + * update watch file: + + use file format 4 + + tighten regular expressions + + use substitution strings + + set dversionmangle=auto + + add usage comment + * update git-buildpackage settings: + + shorten filter + + sign tags + + use DEP-14 git branch names + + add usage comment + * modernize source script copyright-check + * copyright: + + update coverage + * override lintian License-Reference field warnings + (see bug#786450) + * declare compliance with Debian Policy 4.5.1 + * check testsuite, and lint-check code; + build-depend on jest + * use debhelper compatibility level 13 (not 12) + * generate upstream documentation as html and plaintext; + build-depend on pandoc + * build-depend on dh-sequence-nodejs (not pkg-js-tools) + * embed Test-Command within autopkgtest control file + * add patch 2001 to avoid privacy breaches reading the documentation + * add patch 2002 to avoid use of NPM in integration tests + * check integration tests in autopkgtest + * fix stop depend on nodejs + * fix install files, and avoid install tests + + -- Jonas Smedegaard Thu, 17 Dec 2020 04:14:48 +0100 + node-eslint-plugin-html (5.0.5-1) unstable; urgency=medium [ upstream ] diff -Nru node-eslint-plugin-html-5.0.5/debian/control node-eslint-plugin-html-6.1.1/debian/control --- node-eslint-plugin-html-5.0.5/debian/control 2020-06-06 09:26:28.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/control 2020-12-17 03:04:30.000000000 +0000 @@ -6,12 +6,14 @@ Section: javascript Priority: optional Build-Depends: - debhelper-compat (= 12), + debhelper-compat (= 13), + dh-sequence-nodejs, eslint , + jest , node-htmlparser2 (>= 3.10.0) , node-semver (>= 5.6.0) , - pkg-js-tools (>= 0.9.20~), -Standards-Version: 4.5.0 + pandoc , +Standards-Version: 4.5.1 Vcs-Browser: https://salsa.debian.org/js-team/node-eslint-plugin-html Vcs-Git: https://salsa.debian.org/js-team/node-eslint-plugin-html.git Homepage: https://github.com/BenoitZugmeyer/eslint-plugin-html @@ -22,7 +24,6 @@ Depends: node-htmlparser2 (>= 3.10.0), node-semver (>= 5.6.0), - nodejs, ${misc:Depends}, Enhances: eslint, diff -Nru node-eslint-plugin-html-5.0.5/debian/copyright node-eslint-plugin-html-6.1.1/debian/copyright --- node-eslint-plugin-html-5.0.5/debian/copyright 2020-06-06 09:29:23.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/copyright 2020-12-17 02:17:55.000000000 +0000 @@ -4,24 +4,41 @@ Source: https://github.com/BenoitZugmeyer/eslint-plugin-html Files: * -Copyright: 2016, Benoît Zugmeyer +Copyright: + 2016, Benoît Zugmeyer License: ISC -Files: debian/* +Files: + debian/* Copyright: 2016-2020, Jonas Smedegaard 2017, Pirate Praveen -License: ISC + 2020, Purism, SPC +License-Grant: + This program is free software; + you can redistribute it and/or modify it + under the terms of the GNU General Public License + as published by the Free Software Foundation; + either version 3, or (at your option) any later version. +License: GPL-3+ + +License: GPL-3+ +License-Reference: /usr/share/common-licenses/GPL-3 License: ISC - 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. + 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. + 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. diff -Nru node-eslint-plugin-html-5.0.5/debian/copyright-check node-eslint-plugin-html-6.1.1/debian/copyright-check --- node-eslint-plugin-html-5.0.5/debian/copyright-check 2020-04-22 15:41:27.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/copyright-check 2020-12-17 02:17:55.000000000 +0000 @@ -1,5 +1,6 @@ #!/bin/sh -# Copyright 2016-2019, Jonas Smedegaard +# Copyright 2020 Jonas Smedegaard +# Copyright 2020 Purism, SPC # Description: helper script to update copyright_hints # # This program is free software; you can redistribute it and/or modify @@ -17,13 +18,58 @@ set -eu -# extract metadata from graphics files before copyright check -# - and skip data files unlikely to contain copyright/licensing info. -export DEB_COPYRIGHT_EXTRACT_EXTS="gif jpg png" -export DEB_COPYRIGHT_CHECK_IGNORE_EXTS="epgz ico" +SKIPFILES='meta' -make -f /usr/share/cdbs/1/rules/utils.mk pre-build || true -make -f /usr/share/cdbs/1/rules/utils.mk clean DEB_COPYRIGHT_CHECK_STRICT=1 +# cleanup stray hint files from a previous run +find -type f -regextype posix-egrep -regex "^.*:($SKIPFILES)$" -delete -# unconditionally merge changes - safe to do with git-tracked package -[ ! -f debian/copyright_newhints ] || mv -f debian/copyright_newhints debian/copyright_hints +# omit files not copyright protected nor stating copyright or licensing +RE_omit='.*\.(ico)' + +1>&2 echo 'extract metadata from binary files ...' +RE_meta='.*\.png' +exiftool '-textOut!' %d%f.%e:meta -short -short -recurse -ext png . + +RE_SKIP="$RE_omit|$RE_meta" + +# TODO: automate more of this manual cleanup: +# * strip garbage copyright holders +# * optionally merge equally licensed Files sections +# * do "sort -k2 -k1,1 -u" on copyright holders +# * merge copyright years for each copyright holder +# TODO: strip files matching glob in current (only, no later) section +_licensecheck() { + GLOB=$1 + shift + case "$GLOB" in + '*') 1>&2 echo "check default section(s) ...";; + '') 1>&2 echo "check remaining upstream section(s) ...";; + *) 1>&2 echo "check section(s) $GLOB ...";; + esac + licensecheck --copyright --deb-machine --recursive --lines 0 "$@" -- * \ + | GLOB=$GLOB SKIPFILES=$SKIPFILES perl -0777 -p \ + -e 'BEGIN { our $GLOB = join "\n ", split(" ",$ENV{GLOB}) }' \ + -e 's/^.*?\n\nFiles: \K/$GLOB\n /s if $GLOB;' \ + -e 's/^.*?\n\nFiles: \K.*?(?=\n\w)/$GLOB/s if $GLOB and $GLOB =~ /^[*]\//;' \ + -e 's/^.*?\n\n//s unless $GLOB and $GLOB =~ /^[*]$/m;' \ + -e 's/^Files:\K /\n /mg;' \ + -e 's/^Copyright:\K /\n /mg;' \ + -e 's/(?:(?<=^ )|(?<=\d{4})),\K (?=\d{4})//mg;' \ + -e 's/:(?:$ENV{SKIPFILES})$//mg;' \ + >> debian/copyright_hints +} + +rm -f debian/copyright_hints + +# initially, check all to know roughly what to group and in which order +#rm -f debian/copyright_hints +#_licensecheck '' --check '.*' --ignore "^($RE_SKIP|debian/.*)$" +#exit 0 + +# check generally +# * omit non-copyright-protected Debian files +_licensecheck '*' --check '.*' --ignore "^($RE_SKIP|debian/.*)$" +_licensecheck '*/debian' --check '^debian/' --ignore "^($RE_SKIP|debian/(changelog|copyright(_hints)?|source/lintian-overrides))$" + +# cleanup hint files +find -type f -regextype posix-egrep -regex "^.*:($SKIPFILES)$" -delete diff -Nru node-eslint-plugin-html-5.0.5/debian/copyright_hints node-eslint-plugin-html-6.1.1/debian/copyright_hints --- node-eslint-plugin-html-5.0.5/debian/copyright_hints 2020-06-06 09:29:23.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/copyright_hints 2020-12-17 03:25:11.000000000 +0000 @@ -2,21 +2,15 @@ Upstream-Name: FIXME Upstream-Contact: FIXME Source: FIXME -Disclaimer: Autogenerated by CDBS +Disclaimer: Autogenerated by licensecheck -Files: CHANGELOG.md +Files: + * + CHANGELOG.md MIGRATION_TO_V3.md README.md - debian/control - debian/docs - debian/gbp.conf - debian/rules - debian/source/format - debian/tests/control - debian/tests/require - debian/upstream - debian/watch - npm-shrinkwrap.json + media/logo.svg + package-lock.json package.json src/TransformableString.js src/__tests__/.eslintrc.yml @@ -37,25 +31,45 @@ src/__tests__/fixtures/scope-sharing.html src/__tests__/fixtures/self-closing-tags.xhtml src/__tests__/fixtures/simple.html + src/__tests__/getFileMode.js src/__tests__/plugin.js src/extract.js + src/getFileMode.js src/index.js src/settings.js src/utils.js tools/integration-tests.bash + tools/release.js tools/scope-sharing-browser-tests.html -Copyright: NONE +Copyright: + NONE License: UNKNOWN FIXME -Files: debian/copyright-check -Copyright: 2016-2019, Jonas Smedegaard - check -License: GPL-3+ +Files: + LICENSE +Copyright: + 2016, Benoît Zugmeyer +License: ISC FIXME -Files: LICENSE -Copyright: 2016, Benoît Zugmeyer -License: ISC +Files: + */debian +Copyright: + NONE +License: UNKNOWN + FIXME + +Files: + debian/copyright-check +Copyright: + --deb-machine --recursive --lines 0 "$@" -- * + -protected Debian files + 2020, Jonas Smedegaard + 2020, Purism, SPC + K / /mg;' + protected nor stating copyright or licensing + years for each copyright holder +License: GPL-3+ FIXME diff -Nru node-eslint-plugin-html-5.0.5/debian/docs node-eslint-plugin-html-6.1.1/debian/docs --- node-eslint-plugin-html-5.0.5/debian/docs 2020-03-24 14:41:03.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -README.md diff -Nru node-eslint-plugin-html-5.0.5/debian/gbp.conf node-eslint-plugin-html-6.1.1/debian/gbp.conf --- node-eslint-plugin-html-5.0.5/debian/gbp.conf 2020-03-24 14:41:03.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/gbp.conf 2020-12-17 02:17:55.000000000 +0000 @@ -1,5 +1,14 @@ +# clone this source: gbp clone $PKG_GIT_URL +# track upstream source: git remote add upstream-git $UPSTREAM_GIT_URL +# update this source: gbp pull +# update upstream source: git fetch upstream-git --tags +# import upstream release: gbp import-orig --upstream-vcs-tag=$VERSION --uscan +# build package: gbp buildpackage +# publish source release: gbp tag && gbp push + [DEFAULT] pristine-tar = True - -[import-orig] -filter = [ '.gitignore', '.travis.yml', '.git*' ] +sign-tags = True +filter = [ '*/.git*', '.travis.yml' ] +debian-branch = debian/latest +upstream-branch = upstream/latest diff -Nru node-eslint-plugin-html-5.0.5/debian/install node-eslint-plugin-html-6.1.1/debian/install --- node-eslint-plugin-html-5.0.5/debian/install 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/install 2020-12-17 03:04:30.000000000 +0000 @@ -0,0 +1 @@ +package.json src /usr/share/nodejs/eslint-plugin-html diff -Nru node-eslint-plugin-html-5.0.5/debian/patches/2001_privacy.patch node-eslint-plugin-html-6.1.1/debian/patches/2001_privacy.patch --- node-eslint-plugin-html-5.0.5/debian/patches/2001_privacy.patch 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/patches/2001_privacy.patch 2020-12-17 03:24:05.000000000 +0000 @@ -0,0 +1,16 @@ +Description: avoid privacy breaches reading the documentation +Author: Jonas Smedegaard +Last-Update: 2020-12-17 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/README.md ++++ b/README.md +@@ -1,8 +1,6 @@ +
+ +

eslint-plugin-html

+- NPM version +- Tests Status +

A ESLint plugin to lint and fix inline scripts contained in HTML files.

+
+ diff -Nru node-eslint-plugin-html-5.0.5/debian/patches/2002_avoid_npm.patch node-eslint-plugin-html-6.1.1/debian/patches/2002_avoid_npm.patch --- node-eslint-plugin-html-5.0.5/debian/patches/2002_avoid_npm.patch 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/debian/patches/2002_avoid_npm.patch 2020-12-17 03:04:24.000000000 +0000 @@ -0,0 +1,33 @@ +Description: avoid use of NPM in integration tests + Instead, simply assume that both ESLint and this plugin is installed. + . + Also, avoid enabling debug output. +Author: Jonas Smedegaard +Last-Update: 2020-12-17 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/tools/integration-tests.bash ++++ b/tools/integration-tests.bash +@@ -11,13 +11,8 @@ + trap finish EXIT + + REPO_PATH=$(pwd) +-ESLINT_VERSION=${ESLINT_VERSION:-latest} + +-set -x + cd $ROOT +-npm init -y +-npm install --save-dev eslint@$ESLINT_VERSION +-ln -s $REPO_PATH node_modules/eslint-plugin-html + + cat << EOF > index.html + ``` 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 +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 +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 ------------ +## 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` + +- 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` +`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 chose 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! diff -Nru node-eslint-plugin-html-5.0.5/src/extract.js node-eslint-plugin-html-6.1.1/src/extract.js --- node-eslint-plugin-html-5.0.5/src/extract.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/extract.js 2020-11-11 14:19:27.000000000 +0000 @@ -185,7 +185,7 @@ let lineNumber = 1 let previousHTML = "" - iterateScripts(code, { xmlMode, isJavaScriptMIMEType }, chunk => { + iterateScripts(code, { xmlMode, isJavaScriptMIMEType }, (chunk) => { const slice = code.slice(chunk.start, chunk.end) if (chunk.type === "html") { const match = slice.match(/\r\n|\n|\r/g) diff -Nru node-eslint-plugin-html-5.0.5/src/getFileMode.js node-eslint-plugin-html-6.1.1/src/getFileMode.js --- node-eslint-plugin-html-5.0.5/src/getFileMode.js 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/getFileMode.js 2020-11-11 14:19:27.000000000 +0000 @@ -0,0 +1,25 @@ +"use strict" + +module.exports = function getMode(pluginSettings, filenameOrOptions) { + const filename = + typeof filenameOrOptions === "object" + ? filenameOrOptions.filename + : filenameOrOptions + + if (!filename) { + return + } + if (pluginSettings.htmlExtensions.some(hasExtension)) { + return "html" + } + if (pluginSettings.xmlExtensions.some(hasExtension)) { + return "xml" + } + + function hasExtension(extension) { + if (!extension.startsWith(".")) { + extension = `.${extension}` + } + return filename.endsWith(extension) + } +} diff -Nru node-eslint-plugin-html-5.0.5/src/index.js node-eslint-plugin-html-6.1.1/src/index.js --- node-eslint-plugin-html-5.0.5/src/index.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/index.js 2020-11-11 14:19:27.000000000 +0000 @@ -5,6 +5,7 @@ const utils = require("./utils") const splatSet = utils.splatSet const getSettings = require("./settings").getSettings +const getFileMode = require("./getFileMode") const PREPARE_RULE_NAME = "__eslint-plugin-html-prepare" const LINTER_ISPATCHED_PROPERTY_NAME = @@ -20,12 +21,17 @@ // https://github.com/eslint/eslint/issues/3422 // https://github.com/eslint/eslint/issues/4153 -const needle = path.join("lib", "linter.js") +const needles = [ + path.join("lib", "linter", "linter.js"), // ESLint 6+ + path.join("lib", "linter.js"), // ESLint 5- +] iterateESLintModules(patch) function getLinterFromModule(moduleExports) { - return moduleExports.Linter ? moduleExports.Linter : moduleExports + return moduleExports.Linter + ? moduleExports.Linter // ESLint 6+ + : moduleExports // ESLint 5- } function getModuleFromRequire() { @@ -33,7 +39,7 @@ } function getModuleFromCache(key) { - if (!key.endsWith(needle)) return + if (!needles.some((needle) => key.endsWith(needle))) return const module = require.cache[key] if (!module || !module.exports) return @@ -77,7 +83,7 @@ eslintVersion = "n/a" } - const parentPaths = module => + const parentPaths = (module) => module ? [module.filename].concat(parentPaths(module.parent)) : [] throw new Error( @@ -103,30 +109,18 @@ } } -function getMode(pluginSettings, filenameOrOptions) { - const filename = - typeof filenameOrOptions === "object" - ? filenameOrOptions.filename - : filenameOrOptions - const extension = path.extname(filename || "") - - if (pluginSettings.htmlExtensions.indexOf(extension) >= 0) { - return "html" - } - if (pluginSettings.xmlExtensions.indexOf(extension) >= 0) { - return "xml" - } -} - function patch(Linter) { - const verify = Linter.prototype.verify + const verifyMethodName = Linter.prototype._verifyWithoutProcessors + ? "_verifyWithoutProcessors" // ESLint 6+ + : "verify" // ESLint 5- + const verify = Linter.prototype[verifyMethodName] // ignore if verify function is already been patched sometime before if (Linter[LINTER_ISPATCHED_PROPERTY_NAME] === true) { return } Linter[LINTER_ISPATCHED_PROPERTY_NAME] = true - Linter.prototype.verify = function( + Linter.prototype[verifyMethodName] = function ( textOrSourceCode, config, filenameOrOptions, @@ -137,7 +131,7 @@ } const pluginSettings = getSettings(config.settings || {}) - const mode = getMode(pluginSettings, filenameOrOptions) + const mode = getFileMode(pluginSettings, filenameOrOptions) if (!mode || typeof textOrSourceCode !== "string") { return verify.call( @@ -159,7 +153,7 @@ if (pluginSettings.reportBadIndent) { messages.push( - ...extractResult.badIndentationLines.map(line => ({ + ...extractResult.badIndentationLines.map((line) => ({ message: "Bad line indentation.", line, column: 1, @@ -172,7 +166,7 @@ // Save code parts parsed source code so we don't have to parse it twice const sourceCodes = new WeakMap() const verifyCodePart = (codePart, { prepare, ignoreRules } = {}) => { - this.defineRule(PREPARE_RULE_NAME, context => { + this.defineRule(PREPARE_RULE_NAME, (context) => { sourceCodes.set(codePart, context.getSourceCode()) return { Program() { @@ -242,10 +236,10 @@ firstPassValues.push({ codePart, exportedGlobals: globalScope.through.map( - node => node.identifier.name + (node) => node.identifier.name ), declaredGlobals: scopeForDeclaredGlobals.variables.map( - variable => variable.name + (variable) => variable.name ), }) }, @@ -260,17 +254,17 @@ const exportedGlobals = splatSet( firstPassValues .slice(i + 1) - .map(nextValues => nextValues.exportedGlobals) + .map((nextValues) => nextValues.exportedGlobals) ) for (const name of exportedGlobals) context.markVariableAsUsed(name) const declaredGlobals = splatSet( firstPassValues .slice(0, i) - .map(previousValues => previousValues.declaredGlobals) + .map((previousValues) => previousValues.declaredGlobals) ) const scope = context.getScope() - scope.through = scope.through.filter(variable => { + scope.through = scope.through.filter((variable) => { return !declaredGlobals.has(variable.identifier.name) }) }, @@ -280,47 +274,62 @@ function remapMessages(messages, hasBOM, codePart) { const newMessages = [] - const bomOffset = hasBOM ? -1 : 0 for (const message of messages) { - const location = codePart.originalLocation({ - line: message.line, - // eslint-plugin-eslint-comments is raising message with column=0 to bypass ESLint ignore - // comments. Since messages are already ignored at this time, just reset the column to a valid - // number. See https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/70 - column: message.column || 1, - }) - - // Ignore messages if they were in transformed code - if (location) { - Object.assign(message, location) - message.source = codePart.getOriginalLine(location.line) - - // Map fix range - if (message.fix && message.fix.range) { - message.fix.range = [ - codePart.originalIndex(message.fix.range[0]) + bomOffset, - // The range end is exclusive, meaning it should replace all characters with indexes from - // start to end - 1. We have to get the original index of the last targeted character. - codePart.originalIndex(message.fix.range[1] - 1) + 1 + bomOffset, - ] - } - - // Map end location - if (message.endLine && message.endColumn) { - const endLocation = codePart.originalLocation({ - line: message.endLine, - column: message.endColumn, - }) - if (endLocation) { - message.endLine = endLocation.line - message.endColumn = endLocation.column - } - } - + if (remapMessage(message, hasBOM, codePart)) { newMessages.push(message) } } return newMessages } + +function remapMessage(message, hasBOM, codePart) { + if (!message.line || !message.column) { + // Some messages apply to the whole file instead of a particular code location. In particular: + // * @typescript-eslint/parser may send messages with no line/column + // * eslint-plugin-eslint-comments send messages with column=0 to bypass ESLint ignore comments. + // See https://github.com/BenoitZugmeyer/eslint-plugin-html/issues/70 + // For now, just include them in the output. In the future, we should make sure those messages + // are not print twice. + return true + } + + const location = codePart.originalLocation({ + line: message.line, + column: message.column, + }) + + // Ignore messages if they were in transformed code + if (!location) { + return false + } + + Object.assign(message, location) + message.source = codePart.getOriginalLine(location.line) + + // Map fix range + if (message.fix && message.fix.range) { + const bomOffset = hasBOM ? -1 : 0 + message.fix.range = [ + codePart.originalIndex(message.fix.range[0]) + bomOffset, + // The range end is exclusive, meaning it should replace all characters with indexes from + // start to end - 1. We have to get the original index of the last targeted character. + codePart.originalIndex(message.fix.range[1] - 1) + 1 + bomOffset, + ] + } + + // Map end location + if (message.endLine && message.endColumn) { + const endLocation = codePart.originalLocation({ + line: message.endLine, + column: message.endColumn, + }) + if (endLocation) { + message.endLine = endLocation.line + message.endColumn = endLocation.column + } + } + + return true +} diff -Nru node-eslint-plugin-html-5.0.5/src/settings.js node-eslint-plugin-html-6.1.1/src/settings.js --- node-eslint-plugin-html-5.0.5/src/settings.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/settings.js 2020-11-11 14:19:27.000000000 +0000 @@ -20,7 +20,7 @@ function filterOut(array, excludeArray) { if (!excludeArray) return array - return array.filter(item => excludeArray.indexOf(item) < 0) + return array.filter((item) => excludeArray.indexOf(item) < 0) } function compileRegExp(re) { @@ -86,14 +86,14 @@ ? (Array.isArray(rawJavaScriptMIMETypes) ? rawJavaScriptMIMETypes : [rawJavaScriptMIMETypes] - ).map(s => (s.startsWith("/") ? compileRegExp(s) : s)) + ).map((s) => (s.startsWith("/") ? compileRegExp(s) : s)) : [ /^(application|text)\/(x-)?(javascript|babel|ecmascript-6)$/i, /^module$/i, ] function isJavaScriptMIMEType(type) { - return javaScriptMIMETypes.some(o => + return javaScriptMIMETypes.some((o) => typeof o === "string" ? type === o : o.test(type) ) } diff -Nru node-eslint-plugin-html-5.0.5/src/__tests__/extract.js node-eslint-plugin-html-6.1.1/src/__tests__/extract.js --- node-eslint-plugin-html-5.0.5/src/__tests__/extract.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/__tests__/extract.js 2020-11-11 14:19:27.000000000 +0000 @@ -27,7 +27,7 @@ params.xmlMode, params.isJavaScriptMIMEType ) - expect(infos.code.map(code => code.toString())).toMatchSnapshot() + expect(infos.code.map((code) => code.toString())).toMatchSnapshot() expect(infos.badIndentationLines).toEqual(params.badIndentationLines || []) } diff -Nru node-eslint-plugin-html-5.0.5/src/__tests__/getFileMode.js node-eslint-plugin-html-6.1.1/src/__tests__/getFileMode.js --- node-eslint-plugin-html-5.0.5/src/__tests__/getFileMode.js 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/__tests__/getFileMode.js 2020-11-11 14:19:27.000000000 +0000 @@ -0,0 +1,51 @@ +"use strict" + +const getFileMode = require("../getFileMode") + +test("undefined if filename is empty", () => { + expect( + getFileMode({ htmlExtensions: [], xmlExtensions: [] }, undefined) + ).toBe(undefined) +}) + +test("'html' if filename matches an HTML extension", () => { + expect( + getFileMode({ htmlExtensions: ["html"], xmlExtensions: [] }, "foo.html") + ).toBe("html") +}) + +test("'html' if filename matches an HTML and an XML extension", () => { + expect( + getFileMode( + { htmlExtensions: ["html"], xmlExtensions: ["html"] }, + "foo.html" + ) + ).toBe("html") +}) + +test("'xml' if filename matches an XML extension", () => { + expect( + getFileMode({ htmlExtensions: ["html"], xmlExtensions: ["xml"] }, "foo.xml") + ).toBe("xml") +}) + +test("undefined if filename ends with extension without dot", () => { + expect( + getFileMode({ htmlExtensions: [], xmlExtensions: ["xml"] }, "fooxml") + ).toBe(undefined) +}) + +test("works with extensions starting with a dot", () => { + expect( + getFileMode({ htmlExtensions: [".html"], xmlExtensions: [] }, "foo.html") + ).toBe("html") +}) + +test("works with extensions containgin a dot", () => { + expect( + getFileMode( + { htmlExtensions: [".html.in"], xmlExtensions: [] }, + "foo.html.in" + ) + ).toBe("html") +}) diff -Nru node-eslint-plugin-html-5.0.5/src/__tests__/plugin.js node-eslint-plugin-html-6.1.1/src/__tests__/plugin.js --- node-eslint-plugin-html-5.0.5/src/__tests__/plugin.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/__tests__/plugin.js 2020-11-11 14:19:27.000000000 +0000 @@ -6,8 +6,14 @@ const eslintVersion = require("eslint/package.json").version const plugin = require("..") +function matchVersion(versionSpec) { + return semver.satisfies(eslintVersion, versionSpec, { + includePrerelease: true, + }) +} + function ifVersion(versionSpec, fn, ...args) { - const execFn = semver.satisfies(eslintVersion, versionSpec) ? fn : fn.skip + const execFn = matchVersion(versionSpec) ? fn : fn.skip execFn(...args) } @@ -273,24 +279,38 @@ it("should report messages at the beginning of the file", () => { const messages = execute("error-at-the-beginning.html", { rules: { - "max-lines": [2, { max: 1 }], + "max-lines": [2, { max: 3 }], "max-len": [2, { code: 35 }], "no-console": 0, }, }) expect(messages.length).toBe(2) + expect(messages[0].message).toBe( - "Line 1 exceeds the maximum line length of 35." + matchVersion(">= 6") + ? "This line has a length of 70. Maximum allowed is 35." + : "Line 1 exceeds the maximum line length of 35." ) expect(messages[0].line).toBe(1) expect(messages[0].column).toBe(9) expect(messages[1].message).toBe( - "File must be at most 1 lines long. It's 7 lines long." - ) - expect(messages[1].line).toBe(1) - expect(messages[1].column).toBe(9) + matchVersion(">= 7.11") + ? "File has too many lines (6). Maximum allowed is 3." + : matchVersion(">= 6") + ? "File has too many lines (7). Maximum allowed is 3." + : "File must be at most 3 lines long. It's 7 lines long." + ) + // Starting with eslint 7.3, this message is reported at the beginning of the first extra line + // instead of the beginning of the file. + if (matchVersion(">= 7.3")) { + expect(messages[1].line).toBe(4) + expect(messages[1].column).toBe(1) + } else { + expect(messages[1].line).toBe(1) + expect(messages[1].column).toBe(9) + } }) }) diff -Nru node-eslint-plugin-html-5.0.5/src/TransformableString.js node-eslint-plugin-html-6.1.1/src/TransformableString.js --- node-eslint-plugin-html-5.0.5/src/TransformableString.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/TransformableString.js 2020-11-11 14:19:27.000000000 +0000 @@ -88,7 +88,7 @@ ) { this._blocks.push(newBlock) } else { - const index = this._blocks.findIndex(other => other.to > from) + const index = this._blocks.findIndex((other) => other.to > from) if (this._blocks[index].from < to) throw new Error("Can't replace slice") this._blocks.splice(index, 0, newBlock) } diff -Nru node-eslint-plugin-html-5.0.5/src/utils.js node-eslint-plugin-html-6.1.1/src/utils.js --- node-eslint-plugin-html-5.0.5/src/utils.js 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/src/utils.js 2020-11-11 14:19:27.000000000 +0000 @@ -8,7 +8,7 @@ .join("") .trim() .split("\n") - .map(line => line.trim()) + .map((line) => line.trim()) .join(" ") } diff -Nru node-eslint-plugin-html-5.0.5/tools/release.js node-eslint-plugin-html-6.1.1/tools/release.js --- node-eslint-plugin-html-5.0.5/tools/release.js 1970-01-01 00:00:00.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/tools/release.js 2020-11-11 14:19:27.000000000 +0000 @@ -0,0 +1,178 @@ +"use strict" +const { execSync: exec } = require("child_process") +const { readFileSync: read } = require("fs") +const { request } = require("https") + +const REPO = "BenoitZugmeyer/eslint-plugin-html" +const PACKAGE_FILES = [ + "LICENSE", + "src/extract.js", + "src/getFileMode.js", + "src/index.js", + "src/settings.js", + "src/TransformableString.js", + "src/utils.js", + "package.json", + "CHANGELOG.md", + "README.md", +] + +main().catch((error) => { + console.log(error) + process.exitCode = 1 +}) + +async function main() { + const [version, channel] = getVersion() + verifyPackageContent() + runTests() + createVersion(version) + await verifyBuild() + releaseVersion(version, channel) + console.log("Release successful!") +} + +function error(message) { + console.error(message) + process.exit(1) +} + +function getVersion() { + console.log("Get version...") + + // Verify repository status + if (exec("git status --porcelain").length) { + error("Repository should be clean") + } + + const matches = read("CHANGELOG.md") + .toString() + .match( + /^(\d{4}-\d{2}-\d{2}) v(\d+\.\d+\.\d+(?:-([a-z]+)\.\d+)?)(?: - .+)?$/m + ) + + if (!matches) { + error("Invalid changelog format") + } + + const [_, date, version, channel = "latest"] = matches + if (date !== new Date().toISOString().slice(0, 10)) { + error("Invalid changelog date") + } + + return [version, channel] +} + +function runTests() { + console.log("Running tests...") + exec("npm run --silent test", { stdio: "inherit" }) + exec("npm run --silent lint", { stdio: "inherit" }) +} + +function verifyPackageContent() { + console.log("Verify package content...") + const packed = exec("npm pack --dry-run 2>&1").toString().split("\n") + + const STATE_INIT = 0 + const STATE_TARBALL_CONTENTS = 1 + const STATE_TARBALL_DETAILS = 2 + + let state = STATE_INIT + const content = new Set() + + for (let line of packed) { + line = line.replace(/^npm notice /, "").trim() + switch (state) { + case STATE_INIT: + if (line === "=== Tarball Contents ===") { + state = STATE_TARBALL_CONTENTS + } + break + case STATE_TARBALL_CONTENTS: + if (line === "=== Tarball Details ===") { + state = STATE_TARBALL_DETAILS + } else { + content.add(line.match(/.*?\s+(.*)$/)[1]) + } + break + } + } + + const expectedContent = new Set(PACKAGE_FILES) + + for (const file of expectedContent) { + if (!content.has(file)) error(`Missing ${file} in package content`) + } + for (const file of content) { + if (!expectedContent.has(file)) + error(`Unexpected ${file} in package content`) + } +} + +function createVersion(version) { + console.log(`Creating version ${version}`) + + exec(`npm version ${version}`, { + stdio: "inherit", + }) + + exec("git push --no-follow-tags", { + stdio: "inherit", + }) +} + +async function verifyBuild() { + const sha = exec("git rev-parse HEAD").toString().trim() + while (true) { + const { workflow_runs: runs } = await fetchWorkflowRuns() + const run = runs.find((commit) => commit.head_sha === sha) + if (!run) { + console.log("Workflow run not found yet...") + } else { + if (run.status === "completed") { + if (run.conclusion !== "success") { + error(`Workflow run ${run.html_url} finished as ${run.conclusion}`) + } else { + return + } + } else { + console.log(`Workflow run ${run.html_url} ${run.status}`) + } + } + await new Promise((resolve) => setTimeout(resolve, 3000)) + } +} + +function fetchWorkflowRuns() { + return new Promise((resolve, reject) => { + const req = request( + `https://api.github.com/repos/${REPO}/actions/runs?event=push&branch=master`, + { + headers: { + "User-Agent": "release-script/1.0.0", + }, + } + ) + req.on("error", reject) + req.on("response", (response) => { + const datum = [] + response.on("error", reject) + response.on("data", (data) => datum.push(data)) + response.on("end", () => { + resolve(JSON.parse(Buffer.concat(datum))) + }) + }) + req.end() + }) +} + +function releaseVersion(version, channel) { + console.log(`Publishing ${version} to channel ${channel}`) + + exec(`npm publish --tag ${channel}`, { + stdio: "inherit", + }) + exec("git push --tags", { + stdio: "inherit", + }) +} diff -Nru node-eslint-plugin-html-5.0.5/.travis.yml node-eslint-plugin-html-6.1.1/.travis.yml --- node-eslint-plugin-html-5.0.5/.travis.yml 2019-05-13 19:36:46.000000000 +0000 +++ node-eslint-plugin-html-6.1.1/.travis.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -language: node_js - -matrix: - include: - - node_js: 6 - env: ESLINT_VERSION=latest - - node_js: 8 - env: ESLINT_VERSION=latest - - node_js: 10 - env: ESLINT_VERSION=latest - - node_js: 12 - env: ESLINT_VERSION=latest RUN_LINT=true RUN_INTEGRATION=true - - node_js: 12 - env: ESLINT_VERSION=4.7 RUN_INTEGRATION=true - - node_js: 12 - env: ESLINT_VERSION=6.0.0-alpha.1 RUN_INTEGRATION=true - -script: - - if [[ $RUN_LINT = true ]]; then npm run lint; fi - - if [[ $RUN_INTEGRATION = true ]]; then ./tools/integration-tests.bash; fi - - npm install eslint@$ESLINT_VERSION - - npm test