Skip to content

Add scss-lint#976

Merged
rogeruiz merged 9 commits into
uswds:18f-pages-stagingfrom
nickjs:add-scss-lint-config
Feb 2, 2016
Merged

Add scss-lint#976
rogeruiz merged 9 commits into
uswds:18f-pages-stagingfrom
nickjs:add-scss-lint-config

Conversation

@nickjs

@nickjs nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

@maya @mbland

Things

  • Add scss-lint to Gemfile
  • Add 18F's .scss-lint.yml config file
  • Fix a bunch of linter errors in styleguide.scss
  • Add $color-black

Issues

  • There are still a number of SelectorDepth and NestingDepth linter warnings in styleguide.scss. This would require refactoring a bunch of the code to be less nested
  • I haven't cleaned up other scss files yet
  • scss-lint doesn't play nicely with Jekyll front matter. In order to run scss-lint, you need to remove the --- --- from the top of the scss file. See the issue here: front matter in scss is causing grief with scss-lint task jekyll/jekyll#3408

Notes

  • Update your Bundler version :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our styleguide technically states that selectors less the 5 characters can be on one line, I'm not sure if we can configure the linter for this though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, just looked into it, unfortunately scss-lint doesn't offer this config option. How deep should I shave this yak? I could open a PR there too to add an option...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But at the very least we should add this to shortcomings on https://pages.18f.gov/frontend/css-coding-styleguide/#shortcomings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msecret can you remind me what was the convention with mixed short and long selectors?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, 18F/frontend#90. We should also think about changing the convention in the styleguide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msecret sweet, should I revert this change and disable the SingleLinePerSelector linter, or...?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickjs lets keep it for now, I'd prefer to have all selectors on new lines then none.

@msecret

msecret commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

@nickjs, just to check; is the linting also being run on the files in ./assets/_scss? Did those files not report any errors?

@nickjs

nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

@msecret No, sorry, to be clear there are still a tonnnn of linter warnings all across the repo. I just concentrated on styleguide.scss for now. Subsequent PRs could fix other files. I also didn't add a postcommit hook or anything, so it's not like every time you try to commit you're going to get hundreds of warnings in your face. You still need to run scss-lint manually.

@rogeruiz

rogeruiz commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

Would it be possible to have scss-lint only run on files within the _scss directory? The main.scss file for the assets directory only import files from the _scss directory and doesn't need to be linted. This would solve the issue around yaml front-matter.

Also, @nickjs, there are two big issues landing in the next release. These issues are #975 and #974. The latter issue will refactor a lot of the project and separate code from the site and the actual library. The former issue is one I'll be working on, and I'd like to have these changes integrated into that PR. For now we can leave this PR open to discuss this more, but eventually we can work in tandem to get these changes in once those two issues are closer to being resolved.

@nickjs

nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

@rogeruiz Just pushed a change to the scss-lint config to only run on _scss and exclude _scss/lib. Ran it through wc, a default scss-lint with no arguments generates 234 warnings and 0 errors. Honestly, it seems like a lot of them can be easily grepped, I'd be willing to do that if we decide it's worth it to add the linting.

Because of the Jekyll front matter thing I mentioned above, you still need to manually lint styleguide.scss via scss-lint assets/css/styleguide.scss. If we can remove that front matter, we can add it to the default list of files, which will help until the refactor happens in #974.

So, has any work started on either of those issues? Super excited especially for #974, but if not, I'd recommend merging this now. It adds scss-lint without any side effects since it's not integrated into the automated release process. It will be a lot easier for you later on to just add the existing scss-lint to the build mechanism than it would be to add a whole new tool. Plus, if code is eventually going to get refactored, this PR will eventually just be one big merge conflict, so better to merge it in now, no? I'm not gonna be mad if styeguide.scss (and my little refactor here) disappear later on :)

msecret pushed a commit to 18F/frontend that referenced this pull request Feb 1, 2016
Our guidelines say that each selector should be on a new line unless it's less then 5 characters. This cannot currently be enforced with scss-lint.

See uswds/uswds#976 (comment) for reference.
@msecret

msecret commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

I'd be fine adding this now, it's a good start. We could also set the config to lint _scss and setup HoundCI because it will only complain about new code, which would be a great way to move toward reducing the linting errors.

@nickjs

nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

I can commit to cleaning up at least 100 warnings if we merge this ;)

@rogeruiz

rogeruiz commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

Good idea, let's merge this in. Should we include any documentation on this
so far? Or are we going to be using HoundCI for now since it's a manual
process?

On Mon, Feb 1, 2016 at 3:52 PM, Marco Segreto notifications@github.com
wrote:

I'd be fine adding this now, it's a good start. We could also set the
config to lint _scss and setup HoundCI because it will only complain
about new code, which would be a great way to move toward reducing the
linting errors.


Reply to this email directly or view it on GitHub
#976 (comment)
.

Roger Steve Ruiz
804-539-2255
Innovation Specialist @ 18F
General Services Administration
1800 F St. NW, Washington, DC 20405

@nickjs

nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

@msecret already added the config option to lint _scss by default when you run scss-lint (excluding lib/) :)

@rogeruiz just updated the README with linting instructions. Good call.

Totally up to you guys if you want to enable Hound, though still probably good to do a pass at removing as many warnings as possible first.

@nickjs nickjs force-pushed the add-scss-lint-config branch from 4aad7e1 to 5280055 Compare February 1, 2016 21:09
@nickjs

nickjs commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

@maya thanks, fixed.

@maya

maya commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

This is awesome work! I'd like us to include this too. Can you clarify what file(s) we have to remove frontmatter from in order to run scss-lint?

As a side note, we didn't spend a lot of time refactoring the styleguide.scss bc it wasn't part of our distributed code, but thanks for the improvements!

@nickjs

nickjs commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

@maya actually I think the only files I can find that have it that we would care about would be assets/css/styleguide.scss and assets-styleguide/css/homepage.scss. I'm not sure what the difference between those two directories is and if they both should be linted, nor am I familiar enough with Jekyll to say whether the front matter can be removed or not.

I figured, and I figured the code could change at any point, so I didn't spend too much time on it aside from getting it to (mostly) lint (the exception being the SelectorDepth and NestingDepth warnings).

@maya

maya commented Feb 2, 2016

Copy link
Copy Markdown
Contributor

assets-styleguide/css/homepage.scss are the styles for the homepage https://playbook.cio.gov/designstandards/ and assets/css/styleguide.scss are the styles for the styleguide site https://playbook.cio.gov/designstandards/getting-started/ Both import the web design standards SCSS.

@msecret

msecret commented Feb 2, 2016

Copy link
Copy Markdown
Contributor

So I think we should commit this change as is, ensuring that assets/_scss is linted. From here we'll add HoundCI at some point to move out codebase closer to consistency.

@nickjs, if you'd like to take a crack at fixing a bunch of the errors, we'd be very thankful. Maybe that can go in another PR

@rogeruiz

rogeruiz commented Feb 2, 2016

Copy link
Copy Markdown
Contributor

Hey @nickjs. This looks great! Thanks for taking the time to add scss-lint to the project and using our own 18F standards as a config. For now, the front matter issue is mentioned in the README. After #974 and #975, the work done here will be integrated and the front matter issue should be taken care of.

Thanks again! 🚀 🎸

rogeruiz added a commit that referenced this pull request Feb 2, 2016
@rogeruiz rogeruiz merged commit 3bba050 into uswds:18f-pages-staging Feb 2, 2016
@nickjs

nickjs commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

🎉 Thanks @rogeruiz!

@msecret Just to be clear, assets/_scss is currently linted when you just run a default scss-lint. As for what mechanism you choose to run that (Hound, cmd, etc), that is an exercise I leave to the reader :)

@maya

maya commented Feb 3, 2016

Copy link
Copy Markdown
Contributor

@nickjs now that this is merged, we're gonna hold you to those 💯 warnings. Just kidding 😉

Thanks again for the awesome work! ⚡

@nickjs

nickjs commented Feb 4, 2016

Copy link
Copy Markdown
Contributor Author

@maya #987 💥

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants