Merge pull request #623 from danielbayley/master
Improve CSScomb support
This commit is contained in:
commit
266ad49ab4
107
docs/options.md
107
docs/options.md
|
@ -495,6 +495,58 @@ If in CSS values leading 0s immediately preceeding a decimal should be removed o
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [CSS - comb custom config file](#css---comb-custom-config-file)
|
||||||
|
|
||||||
|
**Namespace**: `css`
|
||||||
|
|
||||||
|
**Key**: `configPath`
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
|
||||||
|
**Supported Beautifiers**: [`CSScomb`](#csscomb)
|
||||||
|
|
||||||
|
**Description**:
|
||||||
|
|
||||||
|
Path to custom CSScomb config file, used in absense of a `.csscomb.json` or `.csscomb.cson` at the root of your project. (Supported by CSScomb)
|
||||||
|
|
||||||
|
**Example `.jsbeautifyrc` Configuration**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"css": {
|
||||||
|
"configPath": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### [CSS - comb predefined config](#css---comb-predefined-config)
|
||||||
|
|
||||||
|
**Namespace**: `css`
|
||||||
|
|
||||||
|
**Key**: `predefinedConfig`
|
||||||
|
|
||||||
|
**Default**: `csscomb`
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
|
||||||
|
**Enum**: `csscomb` `yandex` `zen`
|
||||||
|
|
||||||
|
**Supported Beautifiers**: [`CSScomb`](#csscomb)
|
||||||
|
|
||||||
|
**Description**:
|
||||||
|
|
||||||
|
Used if neither a project or custom config file exists. (Supported by CSScomb)
|
||||||
|
|
||||||
|
**Example `.jsbeautifyrc` Configuration**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"css": {
|
||||||
|
"predefinedConfig": "csscomb"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### [D - Config Path](#d---config-path)
|
#### [D - Config Path](#d---config-path)
|
||||||
|
|
||||||
**Namespace**: `d`
|
**Namespace**: `d`
|
||||||
|
@ -5997,6 +6049,61 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### CSScomb
|
||||||
|
|
||||||
|
#### [CSS - comb custom config file](#css---comb-custom-config-file)
|
||||||
|
|
||||||
|
**Namespace**: `css`
|
||||||
|
|
||||||
|
**Key**: `configPath`
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
|
||||||
|
**Supported Beautifiers**: [`CSScomb`](#csscomb)
|
||||||
|
|
||||||
|
**Description**:
|
||||||
|
|
||||||
|
Path to custom CSScomb config file, used in absense of a `.csscomb.json` or `.csscomb.cson` at the root of your project. (Supported by CSScomb)
|
||||||
|
|
||||||
|
**Example `.jsbeautifyrc` Configuration**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"css": {
|
||||||
|
"configPath": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### [CSS - comb predefined config](#css---comb-predefined-config)
|
||||||
|
|
||||||
|
**Namespace**: `css`
|
||||||
|
|
||||||
|
**Key**: `predefinedConfig`
|
||||||
|
|
||||||
|
**Default**: `csscomb`
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
|
||||||
|
**Enum**: `csscomb` `yandex` `zen`
|
||||||
|
|
||||||
|
**Supported Beautifiers**: [`CSScomb`](#csscomb)
|
||||||
|
|
||||||
|
**Description**:
|
||||||
|
|
||||||
|
Used if neither a project or custom config file exists. (Supported by CSScomb)
|
||||||
|
|
||||||
|
**Example `.jsbeautifyrc` Configuration**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"css": {
|
||||||
|
"predefinedConfig": "csscomb"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Gherkin formatter
|
### Gherkin formatter
|
||||||
|
|
||||||
#### [gherkin - Indent size](#gherkin---indent-size)
|
#### [gherkin - Indent size](#gherkin---indent-size)
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
{
|
{
|
||||||
"name": "Zhang YANG",
|
"name": "Zhang YANG",
|
||||||
"url": "https://github.com/ProgramFan"
|
"url": "https://github.com/ProgramFan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Daniel Bayley",
|
||||||
|
"url": "https://github.com/danielbayley"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -83,6 +87,7 @@
|
||||||
"node-dir": "^0.1.8",
|
"node-dir": "^0.1.8",
|
||||||
"node-uuid": "^1.4.3",
|
"node-uuid": "^1.4.3",
|
||||||
"prettydiff": "^1.12.19",
|
"prettydiff": "^1.12.19",
|
||||||
|
"season": "^5.3.0",
|
||||||
"space-pen": "^5.1.1",
|
"space-pen": "^5.1.1",
|
||||||
"strip-json-comments": "^1.0.2",
|
"strip-json-comments": "^1.0.2",
|
||||||
"temp": "^0.8.3",
|
"temp": "^0.8.3",
|
||||||
|
|
|
@ -6,10 +6,13 @@ module.exports = class JSBeautify extends Beautifier
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
# TODO: Add support for options
|
# TODO: Add support for options
|
||||||
CSS: false
|
_:
|
||||||
LESS: false
|
configPath: true
|
||||||
Sass: false
|
predefinedConfig: true
|
||||||
SCSS: false
|
CSS: true
|
||||||
|
LESS: true
|
||||||
|
Sass: true
|
||||||
|
SCSS: true
|
||||||
}
|
}
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
|
@ -18,16 +21,22 @@ module.exports = class JSBeautify extends Beautifier
|
||||||
|
|
||||||
# Require
|
# Require
|
||||||
Comb = require('csscomb')
|
Comb = require('csscomb')
|
||||||
|
expandHomeDir = require('expand-home-dir')
|
||||||
|
CSON = require('season')
|
||||||
|
|
||||||
config = null
|
config = null
|
||||||
try
|
try # Load from project config file, throwing error if neither exist
|
||||||
# Load from Project's .csscomb.json
|
project = atom.project.getDirectories()?[0]
|
||||||
projectConfigPath = atom.project.getDirectories()?[0]?.resolve('.csscomb.json')
|
try
|
||||||
config = require(projectConfigPath) # Will throw error if does not exist
|
config = CSON.readFileSync(project?.resolve '.csscomb.cson')
|
||||||
catch e
|
catch
|
||||||
# Fallback to csscomb
|
config = require(project?.resolve '.csscomb.json')
|
||||||
config = Comb.getConfig('csscomb')
|
catch
|
||||||
# TODO: Add support to select CSSComb predefined config's name
|
try # Load from custom config
|
||||||
|
config = CSON.readFileSync(expandHomeDir options.configPath)
|
||||||
|
catch
|
||||||
|
# Fallback to [selected] CSScomb predifined config
|
||||||
|
config = Comb.getConfig(options.predefinedConfig)
|
||||||
# console.log('config', config, options)
|
# console.log('config', config, options)
|
||||||
# Configure
|
# Configure
|
||||||
comb = new Comb(config)
|
comb = new Comb(config)
|
||||||
|
|
|
@ -83,4 +83,16 @@ module.exports = {
|
||||||
default: false
|
default: false
|
||||||
description: "If in CSS values leading 0s immediately preceeding \
|
description: "If in CSS values leading 0s immediately preceeding \
|
||||||
a decimal should be removed or prevented."
|
a decimal should be removed or prevented."
|
||||||
|
configPath:
|
||||||
|
title: "comb custom config file"
|
||||||
|
type: 'string'
|
||||||
|
default: ""
|
||||||
|
description: "Path to custom CSScomb config file, used in absense of a \
|
||||||
|
`.csscomb.json` or `.csscomb.cson` at the root of your project."
|
||||||
|
predefinedConfig:
|
||||||
|
title: "comb predefined config"
|
||||||
|
type: 'string'
|
||||||
|
default: "csscomb"
|
||||||
|
description: "Used if neither a project or custom config file exists."
|
||||||
|
enum: ["csscomb", "yandex", "zen"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue