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

StylintBear: Implement settings #1796

Merged
merged 1 commit into from Jun 13, 2017
Merged

Conversation

@yash-nisar
Copy link
Member

@yash-nisar yash-nisar commented Jun 1, 2017

Use the implemented settings to generate a config_file and use
that file if the user does not explicitly mention stylint_config.

Closes #1795

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 yash-nisar commented Jun 1, 2017

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 24daa4a to ada9de2 Jun 1, 2017
@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from ada9de2 to fa0de79 Jun 1, 2017
'truncate': True
}

return json.dumps(options)

This comment has been minimized.

@Makman2

Makman2 Jun 1, 2017
Member

please check here if stylint_config is set, so you can avoid creating a temporary file in that case.

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed. :)

if stylint_config:
return '--config', stylint_config, filename
else:
return '--config', config_file, filename

This comment has been minimized.

@Makman2

Makman2 Jun 1, 2017
Member

can be made shorter:

return '--config', stylint_config or config_file, filename

This comment has been minimized.

@Makman2

Makman2 Jun 1, 2017
Member

or if you wanna make it more verbose ;)

return '--config', stylint_config if stylint_config else config_file, filename

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed. :)

'columnSplitter': ' ',
'showHeaders': False,
'truncate': True
}

This comment has been minimized.

@Makman2

Makman2 Jun 1, 2017
Member

wanna inline that directly into the dict above?

options = {
    '...': ...,
    'reporterOptions': {
        'columns': [...]
        ...

I think that makes it easier to understand, as there's more data to read instead of code ;)

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed. :)

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from fa0de79 to 61f1567 Jun 2, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jun 2, 2017

CC @Makman2 , blocked until we get the StylintBear merged.

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 61f1567 to 4bed3b0 Jun 2, 2017
check_valid_property: bool = True,
allow_zero_units: str = 'never',
z_index_normalize: bool = False,
stylint_config: str = ''):

This comment has been minimized.

@Makman2

Makman2 Jun 2, 2017
Member

styling_config: str='' (no space around =)
This is PEP8, so we should follow.
Same applies for all other params above (sorry :3)

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed. Just a matter of find and replace 😛

:param stylint_config:
The location of the ``.stylintrc`` config file.
"""
if not stylint_config:

This comment has been minimized.

@Makman2

Makman2 Jun 2, 2017
Member

rather invert the if ;)

if styling_config:
    return None
else:
    # make json dict

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed.

will be used as the base for your z-index values. Throws an error
if your value is not normalized.
:param stylint_config:
The location of the ``.stylintrc`` config file.

This comment has been minimized.

@Makman2

Makman2 Jun 2, 2017
Member

you don't have to document stylint_config twice. Hm though I think you have to remove the documentation from create_arguments so it appears properly. There's something written in the linter docs on how to document params^^

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

In the JSHintBear, it is documented in create_arguments..

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Removed it from create_arguments though.

This comment has been minimized.

@Makman2

Makman2 Jun 3, 2017
Member

Documentation:
Bear description shall be provided at class level.
If you document your additional parameters inside create_arguments,
generate_config and process_output, beware that conflicting
documentation between them may be overridden. Document duplicated
parameters inside create_arguments first, then in generate_config
and after that inside process_output.

So I was actually wrong, it should be only in create_arguments^^

See http://api.coala.io/en/latest/_modules/coalib/bearlib/abstractions/Linter.html

The location of the ``.stylintrc`` config file.
"""
return ('--config', stylint_config if stylint_config
else config_file, filename)

This comment has been minimized.

@Makman2

Makman2 Jun 2, 2017
Member

maybe like this? easier to read imo, but up to you:

return ('--config',
        stylint_config if stylint_config else config_file,
        filename)

This comment has been minimized.

@yash-nisar

yash-nisar Jun 2, 2017
Author Member

Fixed.

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 4bed3b0 to 0c2851f Jun 2, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jun 2, 2017

Updated @Makman2

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 0c2851f to a8f6114 Jun 3, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jun 3, 2017

Updated @Makman2

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch 2 times, most recently from 2ae330d to 05ec356 Jun 4, 2017
@gitmate-bot gitmate-bot added size/L and removed size/XXL labels Jun 4, 2017
else:
return filename,
return ('--config',
stylint_config if stylint_config else config_file, filename)

This comment has been minimized.

@Makman2

Makman2 Jun 4, 2017
Member

up to you, but I think having each item on a single row is easier to read :)

('--config',
 stylint_config if stylint_config else config_file,
 filename)
@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch 2 times, most recently from 461468e to 5c207c7 Jun 7, 2017
prefix_vars_with_dollar: str='always',
allow_semicolons: str='never',
sort_order: str='alphabetical',
allow_stacked_properties: str='never',

This comment has been minimized.

@Makman2

Makman2 Jun 7, 2017
Member

could you make all those always and never settings to bools? It seems that there are no more values^^

This comment has been minimized.

@yash-nisar

yash-nisar Jun 8, 2017
Author Member

Fixed. :)

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 98a46b8 to b241cad Jun 9, 2017
spaces_inside_parentheses: bool=None,
placeholder: bool=True,
prefix_vars_with_dollar: bool=True,
semicolons: bool=False,

This comment has been minimized.

@Makman2

Makman2 Jun 9, 2017
Member

What's a common default? Maybe we should make it None? Don't know what's best practice for stylint^^

This comment has been minimized.

This comment has been minimized.

@Makman2

Makman2 Jun 9, 2017
Member

Alright, if someone doesn't want to check semicolons at all, he/she shall open an issue :P

This comment has been minimized.

@yash-nisar

yash-nisar Jun 11, 2017
Author Member

Also, see http://stylus-lang.com/docs/css-style.html#example where they don't use semicolons (and have mentioned it as optional).

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch 2 times, most recently from 4c0db31 to eb27f9a Jun 11, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jun 11, 2017

Updated @Makman2

font: 12px Helvetica, Arial, sans-serif
//comment
rgba(0,0,0,.18)

This comment has been minimized.

@yash-nisar

yash-nisar Jun 11, 2017
Author Member

Ugh.

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from eb27f9a to 7c270e8 Jun 11, 2017
:param strict_naming_convention:
By default, ``variable_naming_convention`` only looks at variable
names. If ``strict_naming_convention`` is set to ``True``,
``variable_naming_convention`` will also look at class and

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

two spaces behind "will" and before "also"

color red !important

:param spaces_inside_parentheses:
Enforce or disallow use of extra spaces inside parentheses.

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

hm maybe an example when extra space is enforced and one when it's disallowed?

This comment has been minimized.

@yash-nisar

yash-nisar Jun 13, 2017
Author Member

Example added.

Enforce or disallow use of extra spaces inside parentheses.
:param placeholder:
Enforce extending placeholder vars when using ``@extend(s)``.
:param prefix_vars_with_dollar:

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

what happens if set to False? Is then $ forbidden? Or does it mean "don't care"?

This comment has been minimized.

@yash-nisar

yash-nisar Jun 13, 2017
Author Member

Example added.

stacked_properties: bool=False,
check_valid_property: bool=True,
zero_units: bool=False,
z_index_normalize: bool=False,

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

Shouldn't this be an int?
If that's the case, we should rename the setting to z_index_normalization_base (or similar, at least the base should occur describing that the passed number acts as some kind of base-value 👍)

mixed_spaces_and_tabs: bool=False,
variable_naming_convention: str=None,
strict_naming_convention: bool=False,
none_keyword: bool=False,

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

not sure, is this value a developer preference? If so we should maybe make it to None

prefix_vars_with_dollar: bool=True,
semicolons: bool=False,
sort_order: str='alphabetical',
stacked_properties: bool=False,

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

Is this one a developer preference? I can also assume that many people do mix them if the properties are simple^^ (if my idea of a property is the same like a property in Stylint)

This comment has been minimized.

from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.NpmRequirement import NpmRequirement

setting_map = {True: 'always',

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

ah maybe precede it with an underscore so we "mark it as private". Not that people think they can import this :P

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 7c270e8 to a07fcb9 Jun 13, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jun 13, 2017

@Makman2 Updated.

``0`` is passed to ``indent_size``, hard tabs are assumed.
For example: If ``indent_size = 4`` and
``mixed_spaces_and_tabs = True``, prefer
``s\s\s\smargin\s0`` over ``\tmargin\s0``

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

missing \ before first s

btw this will be escaped by python and will be made a normal whitespace. I'm not sure if rst will render it properly^^
Double escape \ so those backslashes will be visible

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

Btw you use normal slashes above, maybe you should here too^^

(You only have to show the first spaces, not the ones in the middle imo: /s/s/s/smargin 0 instead of /s/s/s/smargin/s0)

@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch 2 times, most recently from ae72414 to 5f505d9 Jun 13, 2017
over
``.className { padding 0 }``
:param check_valid_property:
Check that a property is valid CSS or HTML.

This comment has been minimized.

@Makman2

Makman2 Jun 13, 2017
Member

ah sorry for missing this: we should call this setting check_property_validity, as we don't check valid-properties for something, but we check that they are actually valid :)

Use the implemented settings to generate a `config_file` and use
that file if the user does not explicitly mention `stylint_config`.

Closes #1795
@yash-nisar yash-nisar force-pushed the yash-nisar:stylint-settings branch from 5f505d9 to e4a9d34 Jun 13, 2017
@Makman2
Copy link
Member

@Makman2 Makman2 commented Jun 13, 2017

ack e4a9d34

@Makman2
Copy link
Member

@Makman2 Makman2 commented Jun 13, 2017

@rultor merge

@rultor
Copy link

@rultor rultor commented Jun 13, 2017

@rultor merge

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

@rultor rultor merged commit e4a9d34 into coala:master Jun 13, 2017
6 of 8 checks passed
6 of 8 checks passed
ci/circleci CircleCI is running your tests
Details
continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
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
@rultor
Copy link

@rultor rultor commented Jun 13, 2017

@rultor merge

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

@yash-nisar yash-nisar deleted the yash-nisar:stylint-settings branch Jun 13, 2017
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.

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