Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
mattlewis92 merged 11 commits into htmlhint:master from Benoit-Vasseur:master
Apr 25, 2017
Merged

add rulesdir option #7

mattlewis92 merged 11 commits into htmlhint:master from Benoit-Vasseur:master
Apr 25, 2017

Conversation

@Benoit-Vasseur
Copy link
Contributor

@Benoit-Vasseur Benoit-Vasseur commented Apr 20, 2017

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 ?

Copy link
Contributor Author

Dont't understand why the tests are failing :/ They are green on my machine

Copy link
Member

@mattlewis92 mattlewis92 left a 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
}

// load custom rles
function loadCustomRules(rulesdir) {
Copy link
Member

@mattlewis92 mattlewis92 Apr 20, 2017

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);
Copy link
Member

@mattlewis92 mattlewis92 Apr 20, 2017

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
if (options.customRules) {
options.customRules.forEach(rule => HTMLHint.addRule(rule));
}
if (options.rulesdir) {
Copy link
Member

@mattlewis92 mattlewis92 Apr 20, 2017

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?

}

emitter(options.formatter(report));
emitter(newError(options.formatter(report)));
Copy link
Member

@mattlewis92 mattlewis92 Apr 20, 2017

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.

Copy link
Contributor Author

@Benoit-Vasseur Benoit-Vasseur Apr 21, 2017

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 :/

Copy link
Member

@mattlewis92 mattlewis92 Apr 21, 2017

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 😄

Copy link
Contributor Author

Thanks for the review. Il will try to do the changes tomorrow.

Copy link
Contributor Author

I made the changes.
However the tests are failing on Travis :/ I do not understand why (it works on my machine). Could you look at it ? Thanks.

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);
Copy link
Member

@mattlewis92 mattlewis92 Apr 22, 2017

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

"chai": "^3.5.0",
"codecov-lite": "^0.1.3",
"glob": "^7.1.1",
"mocha": "^3.0.2",
Copy link
Member

@mattlewis92 mattlewis92 Apr 22, 2017

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)

Copy link

codecov-io commented Apr 25, 2017
edited
Loading

Codecov Report

Merging #7 into master will increase coverage by 1.09%.
The diff coverage is 93.75%.

Impacted file tree graph

@@ 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
Impacted Files Coverage Δ
index.js 89.15% <93.75%> (+1.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edbe992...03c185a. Read the comment docs.

@mattlewis92 mattlewis92 merged commit 4f33df4 into htmlhint:master Apr 25, 2017
Copy link
Member

Released as 1.2.0, thanks for the contribution! 💯

Copy link
Contributor Author

Great :)
Thanks for your help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mattlewis92 mattlewis92 mattlewis92 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /