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

New rule: function-opening-parenthesis-space #62

Closed
davidtheclark opened this issue May 15, 2015 · 18 comments
Closed

New rule: function-opening-parenthesis-space #62

davidtheclark opened this issue May 15, 2015 · 18 comments
Assignees
Labels
type: enhancement a new feature that isn't related to rules

Comments

@davidtheclark
Copy link
Contributor

Typical whitespace, probably.

@davidtheclark davidtheclark self-assigned this May 15, 2015
@davidtheclark davidtheclark added the type: enhancement a new feature that isn't related to rules label May 15, 2015
@davidtheclark
Copy link
Contributor Author

Should this be paired with function-closing-parenthesis-space?

Or should we assume that users would always want to enforce the same rules for opening and closing parentheses so combine them into function-parentheses-space?

@davidtheclark
Copy link
Contributor Author

Also, if we were to make that assumption, we could simplify other rules along the same lines --- e.g. function-operator-space could have just "always"|"never" as the option, instead of doing all the before/after business, if we assume that people will always want the same whitespace on either side of the operator. Same goes for selector-combinator-space.

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

I think function-opening-parenthesis-space and close are different according to the purpose.

Or should we assume that users would always want to enforce the same rules for opening and closing parentheses so combine them into function-parentheses-space?

I don't think it a good idea. Enforcing something like calc (...) seems different than calc( ... ).
If we do one rules, it might have 2 options (open/close) with 2 sub options for each (after/before) right ?

But for function-operator-space it's a bit more tricky since you can have +10% value (see color function spec).

@davidtheclark
Copy link
Contributor Author

Also: @MoOx you probably know this from your other postcss plugins, just want to verify that functions in CSS can have spaces between the keyword and the opening parenthesis?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

You mean is something like rgb( 0,0,0, .2 ) working ?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

Oh sorry. You mean is calc () working ?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

For now it's not for var & calc. I need to double check if this works in browsers.

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

calc () doesn't work in firefox. Good point :)
So that especially interesting to report that has an error :)

@davidtheclark
Copy link
Contributor Author

So according to the spec it is supposed to work with whitespace between keyword and parenthesis?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

I don't think so.

@davidtheclark
Copy link
Contributor Author

See http://www.w3.org/TR/css3-syntax/#rule-defs --- looks to me like there's no whitespace allowed between function name and (.

With that in mind I'd propose maybe we change this rule to function-parentheses-space-inside (always/never), enforcing padding: calc( 1px + 2px ) or padding: calc(1px + 2px); and create another rule for function-space-after which would enforce transform: translateX(1%) translateY(2%); or transform: translateX(1%)translateY(2%); (and would have to accept semicolons are the space)

What do you think?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

Since we are a linter, we might want to not just yell on code quality "issue" but also on potential error. So maybe we can create a rule to prevent this kind of issue (space between keyword and parenthesis) ?

@davidtheclark
Copy link
Contributor Author

OK, yeah. If PostCSS doesn't already throw a syntax error for that, we should, makes sense.

function-token-no-space?

(In spec "function-token" = name + ( I think)

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

It doesn't I just checked on cssnext playground.

function-token-no-space

why not :)

@davidtheclark
Copy link
Contributor Author

Ok ... so just to clarify the plan after that discussion: we'll do away with this rule and create three:

  • function-parentheses-inside
  • function-space-after
  • function-token-no-space

Everybody good with that?

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

lgtm

@jeddy3
Copy link
Member

jeddy3 commented May 16, 2015

One thing..did you mean:

function-parentheses-inside-space and instead of function-parentheses-inside?

Otherwise, the breakdown of rules LGTM :)

@davidtheclark
Copy link
Contributor Author

Yep, thanks. I will change #1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement a new feature that isn't related to rules
Development

No branches or pull requests

3 participants