groupe-sii / sonar-web-frontend-reporters

This is a repo of SII continuous integration build system dedicated to Front-end webapps.
22 stars 10 forks source link

v3.0.0 not working with node v4.5.0 #15

Closed lucascampelo closed 7 years ago

lucascampelo commented 7 years ago

First of all, I would like to thank your job here. This plugins is really good. I'm trying to use v3.0.0 with node v4.5.0 but seems not working as expected. Even using the plugin with backward compatibility (ES5), the following error is displayed:

class SonarWebReporters {
^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/lib/api.js:2:27)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

I've tried using require('sonar-web-frontend-reporters').ES5.Reporters or require('sonar-web-frontend-reporters/build/reporters) but both are causing errors. Using this second, the error is another:

TypeError: glob pattern string required
    at new Minimatch (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/node_modules/glob/node_modules/minimatch/minimatch.js:116:11)
    at setopts (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/node_modules/glob/common.js:118:20)
    at new Glob (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/node_modules/glob/glob.js:135:3)
    at glob (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/node_modules/glob/glob.js:75:10)
    at ESLintReporter.launch (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/build/reporters/eslint.reporter.js:37:7)
    at SonarWebReporters.launch (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/build/reporters.js:70:58)
    at /var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/build/reporters.js:50:15
    at Array.forEach (native)
    at SonarWebReporters.launchReporters (/var/www/html/arquitetura/front-end-teste/node_modules/sonar-web-frontend-reporters/build/reporters.js:49:12)
    at Gulp.<anonymous> (/var/www/html/arquitetura/front-end-teste/gulpfile.js:21:21)

How to proceed ?

ValentinGot commented 7 years ago

Hi @lucascampelo,

I'm diving in, i'll let you know.

ValentinGot commented 7 years ago

So i did some tests and the following syntax is indeed not working:

require('sonar-web-frontend-reporters').ES5.Reporters

But for me this one is working:

var SonarWebReporters = require('sonar-web-frontend-reporters/build/reporters');

var sonarWebReporters = new SonarWebReporters('Sonar Web Reporters', {
  "eslint": {
    "src": "src/**/*.js",
    "report": "reports/sonar/eslint.json",
    "rulesFile": ".eslintrc"
  }
});
sonarWebReporters.launchReporters(function () {
  console.log('All reporters have been processed');
});
lucascampelo commented 7 years ago

Great @ValentinGot. For a while, this solution works for me. But the second error quoted on my first comment it's caused by src option. Seems this options don't accept multiple values like src: ['src/**/*.js','!src/bower_components/**']. My report file size is around 51MB. I'm using a .eslintignore file too but seems not matching.

ValentinGot commented 7 years ago

Indeed, the src property don't accept multiple values.

I'm adding the feature right now. It will be available in the next release (3.0.1), this week-end.

For the .eslintignore, we will investigate, meanwhile you will be able to do your work with the multi-globs feature.

lucascampelo commented 7 years ago

Can you show some demo using SonarWebReporters ?

ValentinGot commented 7 years ago

With ES5 backward compatibility, you will have to do something like that:

var SonarWebReporters = require('sonar-web-frontend-reporters/build/reporters');

var sonarWebReporters = new SonarWebReporters('Sonar Web Reporters', {
  "eslint": {
    "src": [ "src/**/*.js", "!src/bower_components/**" ],
    "report": "reports/sonar/eslint.json",
    "rulesFile": ".eslintrc"
  }
});
sonarWebReporters.launchReporters(function () {
  console.log('All reporters have been processed');
});
lucascampelo commented 7 years ago

This example don't work for me. src parameter is directly passed to Glob, which require a string, causing an error. After read glob docs, I'm using something like that:

var SonarWebReporters = require('sonar-web-frontend-reporters/build/reporters');

var sonarWebReporters = new SonarWebReporters('Sonar Web Reporters', {
  "eslint": {
    "src": "src{/fileone.js,/subfolder/**/*.js}",
    "report": "reports/sonar/eslint.json",
    "rulesFile": ".eslintrc"
  }
});
sonarWebReporters.launchReporters(function () {
  console.log('All reporters have been processed');
});

I'm tried to exclude a folder or file, but this feature was removed in v6+.

Thank you for help.

ValentinGot commented 7 years ago

Yep for now the glob parameter is requiring a string, but you will be able to pass an array when i'll publish the 3.0.1.

ValentinGot commented 7 years ago

Released in 3.1.0.