Skip to content

Commit

Permalink
Added Stylint compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta authored and Anantachai Saothong (Manta) committed Apr 15, 2017
1 parent 6bd3720 commit a4fccad
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ First thing first, you must install this script via *NPM*.
npm install stylus-supremacy -g
```

Aftherthat, specifying a source *Stylus* file follows the command.
Aftherthat, specifying a source *Stylus* file follows the command. The formatted content will be printed to the output stream (console/terminal).
```
stylus-supremacy ./path/to/your/file.styl
```
Expand All @@ -24,7 +24,7 @@ The default [formatting options](#formatting-options) will be used, unless you s
stylus-supremacy ./path/to/your/file.styl --options ./path/to/your/options.json
```

Normally, running the command will print out the formatted content to the output stream (console/terminal). However, you may write the formatted content to a file (or many files, if the pattern matches more than one files) by specifying `--outDir` or `-o`, and followed by the path to an output directory.
You may write the formatted content to a file (or many files, if the pattern matches more than one files) by specifying `--outDir` or `-o`, and followed by the path to an output directory.
```
node stylus-supremacy ./path/to/your/file.styl --outDir ./path/to/output/directory
```
Expand Down Expand Up @@ -67,7 +67,7 @@ body {

The `result.tree` is an object generated by *Stylus* internal [parser](https://github.com/SimenB/stylint/blob/master/src/core/parse.js), which represents the whole *Stylus* input in a tree structure. This is useful for debugging purposes.

The `result.warnings` is an array of warning objects genereted by the `format` function. This array should be empty, unless some tokens could not be recognized, which may lead to a lost in translation.
The `result.warnings` is an array of warning objects genereted by the `format` function. This array should be empty, unless some tokens could not be recognized, which may lead to a lost in translation. In that case, please open an issue in our repository to help improving

## Formatting options

Expand All @@ -83,21 +83,64 @@ You can find a sample JSON file containing the default formatting options [here]
|`insertNewLineBeforeElse`|`false`|`true` for always inserting a new-line before *else* keyword, otherwise `false`.|
|`insertSpaceBeforeComment`|`true`|`true` for always inserting a white-space before a comment, otherwise `false`.|
|`insertSpaceAfterComment`|`true`|`true` for always inserting a white-space after a comment, otherwise `false`.|
|`insertSpaceAfterComma`|`true`|`true` for always inserting a white-space after a comma, otherwise `false`. Commas appear in serveral places, for example, a function parameter list, a function call, object properties and so on.|
|`insertSpaceAfterComma`|`true`|`true` for always inserting a white-space after a comma, otherwise `false`. <br>Commas appear in serveral places, for example, a function parameter list, a function call, object properties and so on.|
|`insertSpaceInsideParenthesis`|`false`|`true` for always inserting a white-space after an open parenthesis and before a close parenthesis, otherwise `false`.|
|`insertParenthesisAroundIfCondition`|`true`|`true` for always inserting a pair of parentheses between *if*-condition, otherwise `false`.|
|`insertLeadingZeroBeforeFraction`|`true`|`true` for always inserting a zero before a number that between 1 and 0, otherwise `false`.|
|`tabStopChar`|`"\t"`|This represents a tab-stop string. You may change this to 2-white-space sequence or anything.|
|`newLineChar`|`"\n"`|This represents a new-line character. You may change this to `"\r\n"` if you are using *Microsoft Windows*.|
|`quoteChar`|`"'"`|This represents a quote character that is used to begin and terminate a string. You must choose either single-quote or double-quote.|
|`sortProperties`|`false`|This can be either `false` for doing nothing about the CSS property order, `"alphabetical"` for sorting CSS properties from A to Z, `"grouped"` for sorting CSS properties according to *[Stylint predefined order](https://github.com/SimenB/stylint/blob/master/src/data/ordering.json)*, or an array of property names will sort the properties accordingly (for example, `["display", "margin", "padding"]`).|
|`sortProperties`|`false`|This can be either <br>`false` for doing nothing about the CSS property order, <br>`"alphabetical"` for sorting CSS properties from A to Z, <br>`"grouped"` for sorting CSS properties according to *[Stylint predefined order](https://github.com/SimenB/stylint/blob/master/src/data/ordering.json)*, <br>or an array of property names will sort the properties accordingly (for example, `["display", "margin", "padding"]`).|
|`alwaysUseImport`|`false`|`true` for always using *@import* over *@require*. The difference between *@import* and *@require* is very subtle. Please refer to [the offical guide](http://stylus-lang.com/docs/import.html#require).|
|`alwaysUseNot`|`false`|`true` for always using *not* keyword over *!* operator, otherwise `false`.|
|`alwaysUseAtBlock`|`false`|`true` for always using *@block*, otherwise `false`.|
|`alwaysUseExtends`|`false`|`true` for always using *@extends* over *@extend*, otherwise `false`.|
|`alwaysUseZeroWithoutUnit`|`false`|`true` for always using *0* without unit in property values, otherwise `false`.|
|`reduceMarginAndPaddingValues`|`false`|`true` for always using `margin x` over `margin x x x x`, `margin x y` over `margin x y x y` where `x`, `y` is a property value, otherwise `false`.|

## Stylint compatibility

Note that `"always"` in *Stylint* is equivalent to `true`; `"never"` and `false` are treated like `false`.

|Stylint options|Equivalent options in Stylus Supremacy|
|---|---|
|`blocks`|`alwaysUseAtBlock`|
|`brackets`|`insertBraces`|
|`colons`|`insertColons`|
|`colors`|Not applicable|
|`commaSpace`|`insertSpaceAfterComma`|
|`commentSpace`|`insertSpaceAfterComment`|
|`cssLiteral`|Not applicable|
|`depthLimit`|Not applicable|
|`duplicates`|Not applicable|
|`efficient`|`reduceMarginAndPaddingValues`|
|`exclude`|Not applicable|
|`extendPref`|`alwaysUseExtends`|
|`globalDupe`|Not applicable|
|`groupOutputByFile`|Not applicable|
|`indentPref`|`tabStopChar`|
|`leadingZero`|`insertLeadingZeroBeforeFraction`|
|`maxErrors`|Not applicable|
|`maxWarnings`|Not applicable|
|`mixed`|Not applicable|
|`namingConvention`|Not applicable|
|`namingConventionStrict`|Not applicable|
|`none`|Not applicable|
|`noImportant`|Not applicable|
|`parenSpace`|`insertSpaceInsideParenthesis`|
|`placeholder`|Not applicable|
|`prefixVarsWithDollar`|Not applicable|
|`quotePref`|`quoteChar`; the value must be either `"'"` or `"\""`.|
|`reporterOptions`|Not applicable|
|`semicolons`|`insertSemicolons`|
|`sortOrder`|`sortProperties`|
|`stackedProperties`|Not available|
|`trailingWhitespace`|Not available <br>*Visual Studio Code* can trim trailing whitespace for you. <br>Please find `"editor.trimAutoWhitespace"` in the settings.|
|`universal`|Not applicable|
|`valid`|Not applicable|
|`zeroUnits`|`alwaysUseZeroWithoutUnit`|
|`zIndexNormalize`|Not applicable|

## Limitations and known issues

- Both single-line and multi-line comments may be dropped out because *Stylint* internal [parser](https://github.com/SimenB/stylint/blob/master/src/core/parse.js) did not play well with comments as its purpose is to create an input for CSS transpilation.
Expand Down

0 comments on commit a4fccad

Please sign in to comment.