Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
# function-comma-newline-before
Require a newline or disallow whitespace before the commas of functions.
```css
a { transform: translate(1
, 1) }
/** ↑
* These commas */
```
## Options
`string`: `"always"|"always-multi-line"|"never-multi-line"`
### `"always"`
There *must always* be a newline before the commas.
The following patterns are considered warnings:
```css
a { transform: translate(1,1) }
```
```css
a { transform: translate(1 ,1) }
```
```css
a { transform: translate(1,
1) }
```
The following patterns are *not* considered warnings:
```css
a {
transform: translate(1
,1)
}
```
```css
a {
transform: translate(1
, 1)
}
```
### `"always-multi-line"`
There *must always* be a newline before the commas in multi-line functions.
The following patterns are considered warnings:
```css
a { transform: translate(1,
1) }
```
The following patterns are *not* considered warnings:
```css
a { transform: translate(1,1) }
```
```css
a { transform: translate(1 ,1) }
```
```css
a {
transform: translate(1
,1)
}
```
```css
a {
transform: translate(1
, 1)
}
```
### `"never-multi-line"`
There *must never* be a whitespace before the commas in multi-line functions.
The following patterns are considered warnings:
```css
a { transform: translate(1 ,
1) }
```
The following patterns are *not* considered warnings:
```css
a { transform: translate(1 ,1) }
```
```css
a { transform: translate(1 , 1) }
```
```css
a {
transform: translate(1,
1)
}
```

View File

@@ -0,0 +1,42 @@
"use strict"
const ruleMessages = require("../../utils/ruleMessages")
const validateOptions = require("../../utils/validateOptions")
const whitespaceChecker = require("../../utils/whitespaceChecker")
const functionCommaSpaceChecker = require("../functionCommaSpaceChecker")
const ruleName = "function-comma-newline-before"
const messages = ruleMessages(ruleName, {
expectedBefore: () => "Expected newline before \",\"",
expectedBeforeMultiLine: () => "Expected newline before \",\" in a multi-line function",
rejectedBeforeMultiLine: () => "Unexpected whitespace before \",\" in a multi-line function",
})
const rule = function (expectation) {
const checker = whitespaceChecker("newline", expectation, messages)
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: expectation,
possible: [
"always",
"always-multi-line",
"never-multi-line",
],
})
if (!validOptions) {
return
}
functionCommaSpaceChecker({
root,
result,
locationChecker: checker.beforeAllowingIndentation,
checkedRuleName: ruleName,
})
}
}
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule