matype / stylefmt

stylefmt is a tool that automatically formats stylesheets.
Other
2.1k stars 89 forks source link

User's local .stylelintrc have influence on npm test #166

Closed hudochenkov closed 7 years ago

hudochenkov commented 8 years ago

I just pull this repository, then npm install and then run tests npm test. Half of the tests was failing. It's really weird, because Travis shows that test is ok.

Almost all tests have problems with indentation:

# at-apply
not ok 4 should be equal
  ---
    operator: equal
    expected: |-
      '.toolbar {\n  @apply --toolbar-theme;\n}\n'
    actual: |-
      '.toolbar {\n\t@apply --toolbar-theme;\n}\n'
  ...
# media-indent
not ok 5 should be equal
  ---
    operator: equal
    expected: |-
      '.foo {\n  @media (max-width: 1000px) {\n    display: none;\n  }\n}\n'
    actual: |-
      '.foo {\n\t@media (max-width: 1000px) {\n\t\tdisplay: none;\n\t}\n}\n'
  ...

I found the root of the problem. I have .stylelintrc in my user directory (/Users/aleks/.stylelintrc). Since stylefmt support config in this location it use this config in test which is unacceptable behaviour.

matype commented 8 years ago

@hudochenkov fmm.. stylefmt should refer the closest .stylelintrc using cosmiconfig. (https://github.com/morishitter/stylefmt/blob/master/lib/params.js#L38-L59)

I will investigate the cause.

Thanks.

gucong3000 commented 7 years ago

@hudochenkov , Can you help me do a test? Pull this branch and try again.

hudochenkov commented 7 years ago

It doesn't work.

image

You can try it. Create ~/.stylelintrc:

{
    "rules": {
        "indentation": "tab"
    }
}
gucong3000 commented 7 years ago

@hudochenkov I was Create %HOME%\.stylelintrc: in Windows It is work fine. Did you forget to delete the node-modules and run npm i ?

hudochenkov commented 7 years ago

@gucong3000 I never had your fork, so it's a clean install.

gucong3000 commented 7 years ago

My wife will have a baby tomorrow, I will come back a month later.

hudochenkov commented 7 years ago

@gucong3000 congratulations!

gucong3000 commented 7 years ago

@hudochenkov Fixed in master branch.

hudochenkov commented 7 years ago

Thank you!