Skip to content
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

bears/hypertext: Add HTMLHintBear #1987

Merged
merged 1 commit into from Aug 14, 2017
Merged

bears/hypertext: Add HTMLHintBear #1987

merged 1 commit into from Aug 14, 2017

Conversation

@yash-nisar
Copy link
Member

yash-nisar commented Aug 10, 2017

Add HTMLHintBear that was worked upon by @AsnelChristian.
This PR is a continuation of @AsnelChristian's PR with some
modifications.

Closes #635

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Checklist

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    individually.
    It is not sufficient to have "fixup commits" on your PR,
    our bot will still report the issues for the previous commit.) You will
    likely receive a lot of bot comments and build failures if coala does not
    pass on every single commit!

After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.

Please consider helping us by reviewing other peoples pull requests as well:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@yash-nisar
Copy link
Member Author

yash-nisar commented Aug 10, 2017

@yash-nisar yash-nisar changed the title bears/hypertext: Add HTMLHintBear WIP bears/hypertext: Add HTMLHintBear Aug 10, 2017
@yash-nisar yash-nisar force-pushed the yash-nisar:htmlhint branch from 501a3bb to 38ff9b2 Aug 10, 2017
@yash-nisar yash-nisar changed the title WIP bears/hypertext: Add HTMLHintBear bears/hypertext: Add HTMLHintBear Aug 10, 2017
@linter(executable='htmlhint',
output_format='regex',
output_regex=r'(?P<filename>.+):(?P<line>\d+):(?P<column>\d+):\s*'
r'(?P<message>.+). \[(?P<severity>error|warning)')

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

you should add the closing \] to the regex ;)

@linter(executable='htmlhint',
output_format='regex',
output_regex=r'(?P<filename>.+):(?P<line>\d+):(?P<column>\d+):\s*'
r'(?P<message>.+). \[(?P<severity>error|warning)')

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

What's the dot for after <message>?

This comment has been minimized.

@yash-nisar

yash-nisar Aug 12, 2017 Author Member

That marks the end of the sentence after which the severity begins.
Example:

xyz.html:2:8: The attribute name of [ TYPE ] must be in lowercase. [error/attr-lowercase]

This comment has been minimized.

@SanketDG

SanketDG Aug 12, 2017 Member

you need to escape it then with a \. Also match the whole string not just until error/warning

This comment has been minimized.

@SanketDG

SanketDG Aug 12, 2017 Member

The current . represents any character

This comment has been minimized.

@yash-nisar

yash-nisar Aug 12, 2017 Author Member

Does it look good now @SanketDG ?

disallow_inline_style: bool=True,
enforce_relative_links_in_href: bool=None,
prohibit_unsafe_characters: bool=True,
disallow_inline_script: bool = False,

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

remove spaces around = operator

:param allow_attribute_value_in_double_quotes:
Allow attribute values to be enclosed in double quotes.
For example: If set to ``True``, prefer ``<a href="" title="abc">``
over ``<a href='' title=abc>``.

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

allow sounds like both are allowed, single and double quotes.

This comment has been minimized.

@yash-nisar

yash-nisar Aug 12, 2017 Author Member

Changed it to require_attribute_value_in_double_quotes

:param prohibit_empty_attribute:
Disallow empty values for attributes.
For example: If set to ``True``, prefer
``<input type="button" disabled="disabled">`` over

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

use a different attribute name, that's not the same as its value.

This comment has been minimized.

@yash-nisar

yash-nisar Aug 12, 2017 Author Member

Changed it to prohibit_empty_value_for_attribute

``<input type="button" disabled="disabled">`` over
``<input type="button" disabled>``.
:param prohibit_attribute_duplication:
Disallow the defining of the same attribute more than once in

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

--> Disallow defining the same attribute more than ...

:param enforce_self_close_empty_tag:
Enforce the empty tag to be closed by self.
For example: If set to ``True``, prefer ``<br />`` over ``<br>``.
:param allow_escaped_special_characters:

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

again: You don't allow this case together with other cases, so you need to rename this too require_...

``<span>aaa&gt;bbb&lt;ccc</span>`` over
``<span>aaa>bbb<ccc</span>``.
:param enforce_unique_attribute_id:
Require the ID attributes to be unique in the document.

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

why not call the setting require_... if you already meantion it inside the description?

This comment has been minimized.

@yash-nisar

yash-nisar Aug 12, 2017 Author Member

Cool 👍

Disallow the defining of the same attribute more than once in
a tag. For example: If set to ``True``, prefer
``<img src="a.png" />`` over ``<img src="a.png" src="b.png" />``.
:param use_doctype_at_beginning:

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

again you can use require

``<div id="id1"></div><div id="id1"></div>``.
:param require_title_tag:
Require the ``<title>`` to be present in the ``<head>`` tag.
:param disallow_script_in_head:

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

--> prohibit...

:param disallow_script_in_head:
Prohibit the use of the ``<script>`` tag in the ``<head>`` tag.
:param require_alt_attribute:
Require alt attribute when using images(``img`` tag) and links

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

missing space before (

:param disallow_script_in_head:
Prohibit the use of the ``<script>`` tag in the ``<head>`` tag.
:param require_alt_attribute:
Require alt attribute when using images(``img`` tag) and links

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

you should enclose alt in double quotes

:param enforce_id_class_naming_convention:
Possible values are ``underline``, ``dash``, ``hump`` and ``false``
to disable the rule.

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

Don't mention false, not using the setting should disable it.

For example: If set to ``underline``, prefer
``<div id="aaa_bbb">``.
For example: If set to ``dash``, prefer ``<div id="aaa-bbb">``.
:param disallow_inline_style:

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

--> prohibit

will raise a warning.
:param enforce_relative_links_in_href:
If ``True``, enforce relative links in the ``href`` attribute and
if ``False``, enforce absolute links.

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

--> require

For example: If set to ``True``,
``<li><a href="https://vimeo.com//56931059‎\u0009‎">2012</a></li>``
will raise a warning.
:param disallow_inline_script:

This comment has been minimized.

@Makman2

Makman2 Aug 11, 2017 Member

--> prohibit

@yash-nisar yash-nisar force-pushed the yash-nisar:htmlhint branch from 38ff9b2 to dadbc82 Aug 12, 2017
@SanketDG
Copy link
Member

SanketDG commented Aug 12, 2017

@yash-nisar it should be '(?P<message>.+)\.

@yash-nisar
Copy link
Member Author

yash-nisar commented Aug 12, 2017

Oh, missed that. Will fix it 👍 @Makman2 review possible ?

@yash-nisar yash-nisar force-pushed the yash-nisar:htmlhint branch from dadbc82 to 4530f2c Aug 13, 2017
@linter(executable='htmlhint',
output_format='regex',
output_regex=r'(?P<filename>.+):(?P<line>\d+):(?P<column>\d+):\s*'
r'(?P<message>.+)\. \[(?P<severity>error|warning).+\]')

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

actually I'm wondering why you don't match the period too for the message :)

This comment has been minimized.

@yash-nisar

yash-nisar Aug 14, 2017 Author Member

Done 👍

This comment has been minimized.

@yash-nisar

yash-nisar Aug 14, 2017 Author Member

Done 👍

elif require_relative_links_in_href is False:
options['href-abs-or-rel'] = 'abs'
else:
options['href-abs-or-rel'] = 'false'

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

hm maybe inline it above doing like this:

'href-abs-or-rel': 'rel' if require_relative_links_in_href else
                   'abs' if require_relative_links_in_href is False else
                   'false'

As the assignment is repeated here, we should try to avoid that 👍

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

I would also maybe change the ifs to this to make it more intuitive (but optional, both do the same):

'false' if require_relative_links_in_href is None else
'rel' if require_relative_links_in_href else
'abs'
<!DOCTYPE html>
<SPAN>
</SPAN>

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

this whitespacing on purpose?

{
"inline-script-disabled": true,
"inline-style-disabled": true
}

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

no newline on purpose?

This comment has been minimized.

@yash-nisar

yash-nisar Aug 14, 2017 Author Member

I've faced this issue a lot of times. Should I open an issue for a NewlineBear or similar ?

This comment has been minimized.

@Makman2

Makman2 Aug 14, 2017 Member

SpaceConsistencyBear already supports this ;)

This comment has been minimized.

@yash-nisar

yash-nisar Aug 14, 2017 Author Member

Maybe we should enable that feature on all the files ?

This comment has been minimized.

@Makman2

Makman2 Aug 14, 2017 Member

if you like ;) however sometimes test files shall contain such inconsistencies (not in your case though)

@@ -0,0 +1,3 @@
<!DOCTYPE html>
<a href="test.html">test1</a>
<a href="http://www.alibaba.com/">test1</a>

This comment has been minimized.

@Makman2

Makman2 Aug 13, 2017 Member

also on purpose this missing newline?

@yash-nisar yash-nisar force-pushed the yash-nisar:htmlhint branch from 4530f2c to 87699d8 Aug 14, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Aug 14, 2017

Updated @Makman2

@@ -0,0 +1,2 @@
<!DOCTYPE html>
<input type="submit" value="Submit" type="submit1"/>

This comment has been minimized.

@Makman2

Makman2 Aug 14, 2017 Member

leading space on purpose?

@@ -0,0 +1,2 @@
<!DOCTYPE html>
<input TYPE="submit" value="Submit"/>

This comment has been minimized.

@Makman2

Makman2 Aug 14, 2017 Member

leading space on purpose?

Add `HTMLHintBear` that was worked upon by @AsnelChristian.
This PR is a continuation of @AsnelChristian's PR with some
modifications.

Closes #635
@yash-nisar yash-nisar force-pushed the yash-nisar:htmlhint branch from 87699d8 to b49553a Aug 14, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Aug 14, 2017

Done @Makman2

@Makman2
Copy link
Member

Makman2 commented Aug 14, 2017

ack b49553a

@Makman2
Copy link
Member

Makman2 commented Aug 14, 2017

@rultor merge

@rultor
Copy link

rultor commented Aug 14, 2017

@rultor merge

@Makman2 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit b49553a into coala:master Aug 14, 2017
6 of 9 checks passed
6 of 9 checks passed
ci/circleci CircleCI is running your tests
Details
continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
codecov/project 100% (target 100%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
review/gitmate/commit No issues with this one - go ahead! :)
Details
review/gitmate/manual This commit was acknowledged.
Details
review/gitmate/pr All is well! :) (0 problems solved)
Details
@yash-nisar yash-nisar deleted the yash-nisar:htmlhint branch Aug 14, 2017
@rultor
Copy link

rultor commented Aug 14, 2017

@rultor merge

@Makman2 Done! FYI, the full log is here (took me 2min)

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

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.