diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..720a12b --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +trailingComma: es5 +semi: false diff --git a/.travis.yml b/.travis.yml index 2c59df8..4fc445b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ node_js: script: - if node --version | grep -q v8; then npm run lint; fi - npm install eslint@4.7 && npm test - - npm install eslint@latest && npm test + - if ! node --version | grep -q v4; then npm install eslint@latest && npm test; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 5993ca1..9e119f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +2018-09-22 v4.0.6 +* Ignore script tags with a `src` attribute #102 + 2018-06-20 v4.0.5 * Fix typo regression from v4.0.4 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 893eb9a..ce824b6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-html", - "version": "4.0.5", + "version": "4.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b809093..c94a0a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-html", - "version": "4.0.5", + "version": "4.0.6", "description": "A ESLint plugin to lint and fix inline scripts contained in HTML files.", "license": "ISC", "repository": { diff --git a/src/__tests__/__snapshots__/extract.js.snap b/src/__tests__/__snapshots__/extract.js.snap index 73ec192..63069ed 100644 --- a/src/__tests__/__snapshots__/extract.js.snap +++ b/src/__tests__/__snapshots__/extract.js.snap @@ -165,6 +165,8 @@ Array [ ] `; +exports[`skips script with src attributes 1`] = `Array []`; + exports[`trim last line spaces 1`] = ` Array [ "var foo = 1; diff --git a/src/__tests__/extract.js b/src/__tests__/extract.js index 3f665f2..c87dad2 100644 --- a/src/__tests__/extract.js +++ b/src/__tests__/extract.js @@ -311,3 +311,9 @@ it("handles self closing script tags in xhtml mode", () => { xmlMode: true, }) }) + +it("skips script with src attributes", () => { + test({ + input: '', + }) +}) diff --git a/src/extract.js b/src/extract.js index 4f3d255..21ac0db 100644 --- a/src/extract.js +++ b/src/extract.js @@ -31,6 +31,10 @@ function iterateScripts(code, options, onChunk) { return } + if (attrs.src) { + return + } + inScript = true pushChunk("html", parser.endIndex + 1) }, diff --git a/src/index.js b/src/index.js index 40a24b3..3bb7481 100644 --- a/src/index.js +++ b/src/index.js @@ -75,7 +75,8 @@ function iterateESLintModules(fn) { eslintVersion = "n/a" } - const pluginVersion = require("../package.json").version + const parentPaths = module => + module ? [module.filename].concat(parentPaths(module.parent)) : [] throw new Error( `eslint-plugin-html error: It seems that eslint is not loaded. @@ -85,13 +86,14 @@ In the report, please include *all* those informations: * ESLint version: ${eslintVersion} * ESLint path: ${eslintPath} -* Plugin version: ${pluginVersion} -* Plugin path: ${__dirname} +* Plugin version: ${require("../package.json").version} +* Plugin inclusion paths: ${parentPaths(module).join(", ")} * NodeJS version: ${process.version} -* Content of your lock file (package-lock.json or yarn.lock) +* CLI arguments: ${JSON.stringify(process.argv)} +* Content of your lock file (package-lock.json or yarn.lock) or the output of \`npm list\` * How did you run ESLint (via the command line? an editor plugin?) * The following stack trace: - ${new Error().stack} + ${new Error().stack.slice(10)} `