-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Initial Airbnb stylelint shared config stylelint-config-airbnb
#23
Conversation
A couple of notes:
|
Hello guys, Having an official config for the airbnb css style guide would be very helpful for the community. @ntwb I am checking the changes you did, was looking in the Readme for instructions about how to apply the preset in our local stylelint config, but the section was missing. In case this pull request is merged, having documentation about how to use it would be quite helpful. Thanks in advance |
"eslint-plugin-import": "^1.8.1", | ||
"eslint-plugin-jsx-a11y": "^1.2.3", | ||
"eslint-plugin-react": "^5.1.1", | ||
"stylelint": "^6.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should stylelint and stylelint-scss also be a peerDependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this shouldn't be needed, a few of the other stylelint configurations required the peerDependency to work around an Atom Editor issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - what I mean is, this config is likely compatible with specific versions of stylelint - making it a peer dep allows us to convey "which versions we're compatible with" in a way that fits easily with npm.
If a package wouldn't ever reasonably be installed without X, and it requires X to work, then X must be a dep or a peer dep :-)
@ntwb Sorry for the delay on this! Would you mind addressing these comments, and updating all the deps to the latest versions? In addition, adding documentation as suggested by @DanielaValero would be quite helpful. |
@@ -0,0 +1,3 @@ | |||
{ | |||
"extends": "airbnb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add "root": true
to this as well
@ljharb I've bumped them all apart from ESLint to 3.x per airbnb/javascript#936 |
"homepage": "https://github.com/airbnb/css#readme", | ||
"devDependencies": { | ||
"eslint": "^2.13.1", | ||
"eslint-config-airbnb": "^9.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually since we don't use react in this project, you could use eslint-config-airbnb-base
- the latest of which does support eslint v3 :-)
@ljharb Is that everything? I've got more enhancements that can be added such as tests and some more SCSS rules but I'd rather look at that over the weekend and send those via PR's... |
"eslint": "^2.13.1", | ||
"eslint-config-airbnb": "^9.0.1", | ||
"eslint": "^3.0.1", | ||
"eslint-config-airbnb-base": "^4.0.0", | ||
"eslint-plugin-import": "^1.10.2", | ||
"eslint-plugin-jsx-a11y": "^1.5.5", | ||
"eslint-plugin-react": "^5.2.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means the react and jsx-a11y plugins aren't needed anymore
I don't think this will be able to be merged before next week - I need to run it by some colleagues first. It's totally fine if you want to add those things to a separate PR (or to this one if it's not merged by the time you're done). |
Cool, I'll just keep pushing commits here then 👍 Not sure if you can turn Travis CI on for this repo but now that there's a |
Good call - it's now enabled whenever there's a .travis.yml at the root. Please continue to mirror the "javascript" repo's organization :-) |
At the root won't work here then will it?
👍 |
@ntwb The JS repo has two subpackages and a root .travis.yml file - you can probably just copy + modify the one from there. |
Hello @ntwb I cloned your fork and made two commits to apply two fixes into the code, however the pull request can be made only to the original repo. Here the two relevant commits: https://github.com/DanielaValero/css/commits/master Also I've set up a stylelint config with all the config of airbnb, plus some best practices: https://gist.github.com/DanielaValero/b3a72b2f3d0c85c1985d5d2d7497f347 I was trying to come up with a regex to lint the naming convention for the variables, but did not figure it out quite right.. This is the last state I could get to: 'scss/dollar-variable-pattern': '\b[a-z]+(?:-)+(\b[a-z]+(?:-))*' |
@DanielaValero Thanks, I've merged those two commits 👍 I messed up a pull request, but @DanielaValero you should be able to create pull requests against my fork and they will be added here to this pull request once merged, I think 😏 Do you want to try that with some of the changes you have in your gist? |
'stylelint-scss', | ||
], | ||
rules: { | ||
'at-rule-empty-line-before': 'never', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm kind of surprised that this plugin doesn't have a prefix on its rule names - ie, stylelint-scss/indentation
- to avoid the risk of colliding with core eslint rules :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's 3am and much wine so forgive me if I interpret this a little wrong 😏
- The rule
at-rule-empty-line-before
your comment refers to is a core stylelint rule, it is not a rule from thestylelint-scss
plugin, you can see a prefixed example of this rule for that plugin here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right but it's still appearing in an eslint config, so it could still conflict with a core eslint rule. i'm saying core stylelint rules should be prefixed with "stylelint/"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll reiterate my previous comment, it's late, its 3am and much wine has passed 😬
This is not an ESLint configuration file, this is a stylelint configuration file
This repo has nothing to do with ESLint (aside ESLint lints the codebase)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok that's just my confusion then :-) in that case, eslint shouldn't be a peer dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehehehe
@ntwb sounds like a plan, I'll do a pull request on your fork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a .travis.yml
at the root that runs the scripts in the package - see https://github.com/airbnb/javascript/blob/master/.travis.yml for an example.
directories: | ||
- node_modules | ||
node_js: | ||
- '6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add 5
and 7
for completeness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ea3ef3d
Unfortunately, there are a lot of scss-lint rules that are enabled by default, so they are implicitly part of our scss-lint configuration. It would be nice if the stylelint configuration captured these. You can see the default set here: https://github.com/brigade/scss-lint/blob/master/config/default.yml |
@lencioni Not entirely sure what you mean here, there are only two SCSS lint rules in the PR currently, Any reasons as to what is what is not in this initial pull request is because there is no other documentation of the Airbnb CSS elsewhere... I'd also like not have to continue to iterate on this one single pull request, it would be nice to get this merged initially and then build on it with further pull requests and an NPM release can then follow once the configuration is ready for launch so to speak. |
I may be misunderstanding the intent here, but if it is to produce a stylelint configuration file that would be equivalent the scss-lint configuration in this repo, then I am suggesting that it capture the spirit of all the rules that scss-lint enables by default in addition to the rules that are explicitly enabled in the scss-lint configuration in this repo. They don't need to be the same rules, but they should cover the same scenarios. |
@lencioni Cool, I'm with you now 👍 There will be a bit of time involved in going through that set of default scss-lint rules to their equivalent stylelint-css and stylelint-scss rules. I'll find a place/repo to document these so that I need only do this once and is also then available for others as a reference 💥 |
If you are going through the trouble anyway, it might not be a bad idea to pull all of the default rules into the scss-lint config here as well. |
Yeah I will, it can be either in this PR, or a follow up PR, I add to add my last commit via the GutHub GUI as my local branch is full of conflicts 😖 Iteration is our friend ;) |
Any help wanted? Would be very nice to see |
@ntwb What's the reasoning behind the blacklist for border? "declaration-property-value-blacklist": {
"/^border/": ["none"]
} |
To disallow the value There was more than likely some Airbnb code I reference that showed the preference was |
@ntwb I understood what the code does, was curious why you wanted to prevent Our team was preferring I'm really looking forward to being able to point at an airbnb opinion on css linting, specifically this stylelint shared config. Thank you for your efforts! |
Thanks @TrevorSayre what I meant was I must have made that decision based off of an Airbnb code example somewhere, it also could have been a decision I made as we'd discussed this rule and the |
@ljharb What's stalling this PR? Is there anything that still needs to be done to achieve acceptance? |
@TrevorSayre My comment here describes what's still needed. |
The Travis CI changes you requested there @ljharb were added the same day were they not? |
No, i requested "at the root" (of the repo) since travis doesn't know about "packages" - similarly to how the javascript repo does it. |
I've got a heap of merge conflicts, can you just merge this pull request so it can be iterated on please |
@ntwb then can you check the "allow edits" box on the right hand column, so i can rebase it for you? |
Done, I never knew that was a thing, it's an awesome thing matter of fact 👍 |
k, rebased. travis.yml still needs to be fixed. |
Hey, great work so far! I assume the travis.yml has to be changed to something like the airbnb/javascript/.travis.yml, right? |
Add NodeJS v5.x & v7.x to Travis CI configuration
Closing in favour of #56 |
See #13