-
-
Notifications
You must be signed in to change notification settings - Fork 8
add rulesdir option #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…(friendly-errors-webpack-plugin)
Dont't understand why the tests are failing :/ They are green on my machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, thanks! Could you also add a test for the new feature + document its usage in the readme.
index.js
Outdated
@@ -40,11 +40,42 @@ function defaultFormatter(messages) { | |||
return output.trim(); | |||
} | |||
|
|||
// load custom rles | |||
function loadCustomRules(rulesdir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this function be replaced with a call to node-glob?
index.js
Outdated
/* eslint-disable import/no-dynamic-require */ // --> OFF | ||
filepath = path.resolve(filepath); | ||
try { | ||
var module = require(filepath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this line to const module = require(filepath); // eslint-disable-line import/no-dynamic-require
. I also would use a different variable instead of module to prevent shadowing the global module variable. Maybe rule
instead?
index.js
Outdated
function lint(source, options, webpack, done) { | ||
try { | ||
if (options.customRules) { | ||
options.customRules.forEach(rule => HTMLHint.addRule(rule)); | ||
} | ||
if (options.rulesdir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you camelcase this option to rulesDir
instead?
index.js
Outdated
@@ -80,7 +111,7 @@ function lint(source, options, webpack, done) { | |||
emitter = webpack.emitWarning; | |||
} | |||
|
|||
emitter(options.formatter(report)); | |||
emitter(new Error(options.formatter(report))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the tests are failing because this is now being emitted as an error. This shouldn't be the case, especially if emitting as a warning not an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my dev machine all the tests are green. And I added this because of a warning in friendly-errors-webpack-plugin : "value string instead of error instance".
I do not understand why they are failing on Travis :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, I realised what was going wrong, travis + my local dev envrionment uses the yarn.lock which has an older version of webpack in the dependencies. It seems like webpack introduced a breaking change between 2.2.1
and 2.4.1
that throws if you emit non errors. If you sync your branch with master the tests should start passing 😄
Thanks for the review. Il will try to do the changes tomorrow. |
I made the changes. |
index.js
Outdated
const ruleOption = options[ruleObj.id]; // we can pass a value to the rule | ||
ruleObj.rule(HTMLHint, ruleOption); | ||
} catch (err) { | ||
throw new Error(err.message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this try catch necessary? By wrapping it like this you'll lose the stack trace etc
package.json
Outdated
@@ -39,6 +40,7 @@ | |||
"devDependencies": { | |||
"chai": "^3.5.0", | |||
"codecov-lite": "^0.1.3", | |||
"glob": "^7.1.1", | |||
"mocha": "^3.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a dependency, not a dev dependency (also make sure the yarn.lock file is updated)
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
==========================================
+ Coverage 88.05% 89.15% +1.09%
==========================================
Files 1 1
Lines 67 83 +16
==========================================
+ Hits 59 74 +15
- Misses 8 9 +1
Continue to review full report at Codecov.
|
Released as 1.2.0, thanks for the contribution! 💯 |
Great :) |
Hi,
We are curently using VueJs and to be able to have your loader working we had to use the rulesdir feature of HtmlHint.
We think this could be useful for anyone.
The code is inspired by HtmlHint itself : https://github.com/yaniswang/HTMLHint/blob/152a114f277645474ca1f70d68a0e01e75f3eb51/bin/htmlhint#L142 .
What do you think ?