webhintio / hint

💡 A hinting engine for the web
https://webhint.io/
Apache License 2.0
3.63k stars 684 forks source link

Sonarwhal command triggers the npm start script in package.json #734

Closed alexbech closed 6 years ago

alexbech commented 6 years ago

When I run the sonarwhal command in my project root directory, it seems to trigger the start script in our package.json file. The Sonarwhal config is in a separate .sonarwhalrc file.

Please tell us about your:

Environment

sonarwhal configuration

sonarwhal’s configuration ```js { "browserslist": [], "connector": { "name": "jsdom", "options": { "waitFor": 1000 } }, "formatters": [ "stylish" ], "ignoredUrls": [], "rules": { "amp-validator": "off", "apple-touch-icons": "error", "axe": "error", "content-type": "error", "disown-opener": "error", "highest-available-document-mode": "error", "html-checker": "error", "http-cache": "error", "image-optimization-cloudinary": "off", "manifest-app-name": "error", "manifest-exists": "error", "manifest-file-extension": "error", "manifest-is-valid": "error", "meta-charset-utf-8": "error", "meta-viewport": "error", "no-disallowed-headers": "error", "no-friendly-error-pages": "error", "no-html-only-headers": "error", "no-http-redirects": "error", "no-protocol-relative-urls": "error", "no-disallowed-headers": "off", "no-vulnerable-javascript-libraries": "error", "ssllabs": "off", "strict-transport-security": "off", "validate-set-cookie-header": "error", "x-content-type-options": "error" }, "rulesTimeout": 120000 } ```

URL for which sonarwhal failed

Output

Please include the raw output generated by sonarwhal, or if possible, the raw output from running sonarwhal in debug mode: sonarwhal --debug <URL>.

sonarwhal’s raw output ```text $ sonarwhal https://www.vaersaagod.no Building! ENV is DEVELOPMENT / Downloading https://www.vaersaagod.no/[Browsersync] Proxying: http://selvaag.test [Browsersync] Access URLs: ---------------------------------- Local: http://localhost:3006 External: http://10.0.1.5:3006 ---------------------------------- UI: http://localhost:3007 UI External: http://10.0.1.5:3007 ---------------------------------- [Browsersync] Watching files... \ Traversing the DOMwebpack built c05dc7afce89a586ba69 in 4657ms Hash: c05dc7afce89a586ba69 Version: webpack 3.8.1 Time: 4657ms Asset Size Chunks Chunk Names fonts/work-sans-400.woff2 22.3 kB [emitted] fonts/chap-light.woff 40.1 kB [emitted] fonts/work-sans-300.woff 27.8 kB [emitted] fonts/work-sans-300.woff2 22.8 kB [emitted] fonts/work-sans-400.woff 27.3 kB [emitted] fonts/chap-light.woff2 26.2 kB [emitted] fonts/work-sans-500.woff 29.4 kB [emitted] fonts/work-sans-500.woff2 24.1 kB [emitted] index.5e4704ce266272dc46ca.js 85.4 kB 0 [emitted] index player.4a90bcc0cef74a814c50.js 164 kB 1 [emitted] player bundle.js 2.98 MB 2 [emitted] [big] bundle [./node_modules/@vaersaagod/tools/Components.js] ./node_modules/@vaersaagod/tools/Components.js 14.4 kB {2} [built] [./node_modules/@vaersaagod/tools/Viewport.js] ./node_modules/@vaersaagod/tools/Viewport.js 10.8 kB {2} [built] [./node_modules/css-loader/index.js?{"minimize":true,"sourceMap":true,"importLoaders":true}!./node_modules/postcss-loader/lib/index.js?{"sourceMap":true,"config":{"path":".conf/postcss.config.js"}}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./src/css/main.scss] ./node_modules/css-loader?{"minimize":true,"sourceMap":true,"importLoaders":true}!./node_modules/postcss-loader/lib?{"sourceMap":true,"config":{"path":".conf/postcss.config.js"}}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./src/css/main.scss 284 kB {2} [built] [./node_modules/doc-ready/doc-ready.js] ./node_modules/doc-ready/doc-ready.js 1.78 kB {2} [built] [./node_modules/eventsource-polyfill/dist/browserify-eventsource.js] ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js 852 bytes {2} [built] [./node_modules/eventsource-polyfill/dist/eventsource.js] ./node_modules/eventsource-polyfill/dist/eventsource.js 17.7 kB {2} [built] [./node_modules/gsap/TweenMax.js] ./node_modules/gsap/TweenMax.js 368 kB {2} [built] [./node_modules/strip-ansi/index.js] ./node_modules/strip-ansi/index.js 161 bytes {2} [built] [0] multi eventsource-polyfill webpack-hot-middleware/client src/js/main.js src/css/main.scss 64 bytes {2} [built] [./node_modules/style-loader/addStyles.js] ./node_modules/style-loader/addStyles.js 8.51 kB {2} [built] [./node_modules/webpack-hot-middleware/client-overlay.js] (webpack)-hot-middleware/client-overlay.js 1.82 kB {2} [built] [./node_modules/webpack-hot-middleware/client.js] (webpack)-hot-middleware/client.js 7.04 kB {2} [built] [./src/css/main.scss] ./src/css/main.scss 1.28 kB {2} [built] [./src/js/lib/polyfills.js] ./src/js/lib/polyfills.js 522 bytes {2} [built] [./src/js/main.js] ./src/js/main.js 1.05 kB {2} [built] + 99 hidden modules webpack: Compiled successfully. ✖ Finishing... https://www.vaersaagod.no/ Error 'set-cookie' header to set '_ia' doesn't have the 'secure' directive. validate-set-cookie-header Error 'set-cookie' header to set '_ia' doesn't have the 'httponly' directive. validate-set-cookie-header Error The directive "must-revalidate" is not recommended http-cache Error 'x-ua-compatible' header was not specified highest-available-document-mode line 3 col 1 Error Meta tag usage is discouraged, use equivalent HTTP header highest-available-document-mode line 11 col 64 Error A charset meta tag was already specified meta-charset-utf-8 line 12 col 1 Error 'sizes' attribute is not needed apple-touch-icons line 15 col 39 Error The file extension should be 'webmanifest' (not 'json') manifest-file-extension line 18 col 64 Error A document must not include both a “meta” element with an “http-equiv” attribute whose value is “content-type”, and a “meta” element with a “charset” attribute. html-checker line 123 col 3 Warning The “banner” role is unnecessary for element “header”. html-checker line 125 col 11 Warning Empty heading. html-checker line 127 col 17 Error Images must have alternate text axe line 136 col 5 Warning The “navigation” role is unnecessary for element “nav”. html-checker line 142 col 17 Error Images must have alternate text axe line 158 col 17 Error Images must have alternate text axe line 178 col 3 Warning The “main” role is unnecessary for element “main”. html-checker line 184 col 5 Error An “img” element must have an “alt” attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. html-checker line 189 col 53 Error 'Besøk nettside ' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 204 col 51 Error 'Grafill' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 323 col 66 Error '' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 324 col 66 Error '' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 329 col 80 Error 'Jon Arne Berg' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 329 col 149 Error 'byHands' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 329 col 254 Error 'Anders Bergh' is missing 'rel' values 'noopener', 'noreferrer' disown-opener line 364 col 3 Warning The “contentinfo” role is unnecessary for element “footer”. html-checker ✖ Found 20 errors and 5 warnings https://www.vaersaagod.no/assets/img/ill3_full@2x.png line 158 col 17 Error 'x-content-type-options' header was not specified x-content-type-options line 158 col 17 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 2 errors and 0 warnings https://www.vaersaagod.no/assets/img/ill2_full@2x.png line 142 col 17 Error 'x-content-type-options' header was not specified x-content-type-options line 142 col 17 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 2 errors and 0 warnings https://www.vaersaagod.no/assets/img/ill1_full@2x.png line 127 col 17 Error 'x-content-type-options' header was not specified x-content-type-options line 127 col 17 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 2 errors and 0 warnings https://www.vaersaagod.no/assets/build/css/1499769416/main.css line 24 col 3 Error 'content-type' header should have 'charset=utf-8' content-type line 24 col 3 Error 'x-content-type-options' header was not specified x-content-type-options line 24 col 3 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 3 errors and 0 warnings https://www.vaersaagod.no/assets/build/js/1499769634/bundle.js line 332 col 9 Error 'content-type' header should have media type 'text/javascript' (not 'application/javascript') content-type line 332 col 9 Error 'x-content-type-options' header was not specified x-content-type-options line 332 col 9 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 3 errors and 0 warnings https://www.vaersaagod.no/assets/build/js/1499769634/Main.js line 58 col 20 Error 'content-type' header should have media type 'text/javascript' (not 'application/javascript') content-type line 58 col 20 Error 'x-content-type-options' header was not specified x-content-type-options line 58 col 20 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 3 errors and 0 warnings https://www.vaersaagod.no/manifest.json line 15 col 1 Error 'content-type' header should have media type 'application/manifest+json' (not 'application/json') content-type line 15 col 1 Error No "cache-control" header or empty value found. It should have a value http-cache line 15 col 1 Error 'x-frame-options', 'x-xss-protection' headers are not needed no-html-only-headers line 15 col 1 Error 'content-type' header should have 'charset=utf-8' content-type ✖ Found 4 errors and 0 warnings https://www.vaersaagod.no/assets/build/img/favicon-32x32.png line 13 col 1 Error 'x-content-type-options' header was not specified x-content-type-options line 13 col 1 Error The directive "must-revalidate" is not recommended http-cache ✖ Found 2 errors and 0 warnings ✖ Found a total of 41 errors and 5 warnings ```
alrra commented 6 years ago

@alexbech If possible, can you also share the content of your package.json file (or at least the scripts part). Thanks!

alexbech commented 6 years ago

The relevant part of our package.json file.

{
  "name": "selvaag",
  "version": "1.1.0",
  "description": "Selvaag Art Collection",
  "main": "index.js",
  "scripts": {
    "start": "npm-run-all --parallel build:dev watch:*",
    "build:dev": "node .",
    "build": "yarn wipe && NODE_ENV=production webpack --config ./.conf/webpack.config.js -p --progress --colors && yarn imagemin"
  }
}
molant commented 6 years ago

@alexbech if I understand correctly the output you are actually testing a local server and not the public URL, right?

[Browsersync] Proxying: http://selvaag.test
[Browsersync] Access URLs:
 ----------------------------------
       Local: http://localhost:3006
    External: http://10.0.1.5:3006
 ----------------------------------
          UI: http://localhost:3007
 UI External: http://10.0.1.5:3007
 ----------------------------------
[Browsersync] Watching files...

Could it be that you have something watching that folder and sonarwhal is triggering the build because of that? The build process doesn't seem to start until Downloading https://www.vaersaagod.no/ which happens when sonarwhal does the request to that url.

alexbech commented 6 years ago

@molant No, this happens with whatever url I test - not only my local server. There are no watch tasks running in the background. There is however an index.js in my project root folder that contains most of our build logic. When I commented out the contents of this file everything seems fine. Why is my index.js executed when i run sonarwhal?

molant commented 6 years ago

Maybe we are doing a require where we shouldn't?

Let me see if I have your set up right so we can keep trying to repro:

I think it's probably related to resourceLoader

alexbech commented 6 years ago

You got it exactly right, and I'm on Mac OSX El Capitan.


$ sonarwhal https://example.com
yeah, it's called
✖ Finishing...
https://example.com/
alrra commented 6 years ago

I cannot reproduce this on macOS High Sierra :(


@alexbech If you have time can you:

1) Test using this (just do sonarwhal example.com from inside of the directory)? If it fails, can you maybe give us some other information that you think might help us reproduce the problem (e.g.: what is the output for npm ls -g --depth=0?)

2) Also test if you have the same problem if sonarwhal is install locally (just do npm i and then npm t inside of the directory)?


And thank you for taking the time to open this issue and helping us with information, we sincerely appreciate it! 💜

alexbech commented 6 years ago

Downloaded and tested both variants above, still get the output from index.js.

sonarwhal example.com
yeah, it's called
✖ Finishing...
http://example.com/

The output of npm ls -g --depth=0

npm ls -g --depth=0
/Users/alexbech/.nvm/versions/node/v8.9.4/lib
├── npm@5.6.0
└── sonarwhal@0.20.1

npm ERR! invalid: minizlib@1.0.3 /Users/alexbech/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
npm ERR! peer dep missing: ajv@^5.0.0, required by ajv-keywords@2.1.1

I've got both yarn and nvm installed too - could this affect the behaviour in any way?

alexbech commented 6 years ago

Hang on, I just noticed that my globally installed sonarwhal was at 0.20.1. Ran npm install -g --engine-strict sonarwhal and got version 0.21.0 and now everything works.

alrra commented 6 years ago

I've got both yarn and nvm installed too - could this affect the behaviour in any way?

They shouldn't.

(I'm also using nvm, and when I tested, seeing that you used yarn, I installed and also used it to see if it could cause the problem).

and got version 0.21.0

Yes, we released it today.

and now everything works.

🎉

Let us know if you hit the problem again.

alexbech commented 6 years ago

Thanks, will do!