Skip to content

Commit

Permalink
Merge pull request #656 from sasstools/release/1.7.0
Browse files Browse the repository at this point in the history
Release/1.7.0
  • Loading branch information
DanPurdy committed Apr 27, 2016
2 parents 058afec + 9f52bc2 commit e364a25
Show file tree
Hide file tree
Showing 19 changed files with 582 additions and 188 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Sass Lint Changelog

## v1.7.0

**April 27, 2016**

You wait months for one release and then four come along in a week!

**Fixes**
* Fixed an issue with final newline not registering correctly for `.sass` syntax [#627](https://github.com/sasstools/sass-lint/issues/627) & [#630](https://github.com/sasstools/sass-lint/issues/630).
* Fixed an issue with `placeholder-name-format` generating warnings on variables used as placeholder names.
* Fixed the `empty-args` rule being wrongly labeled as `no-empty-args` in lint warnings/errors [#625](https://github.com/sasstools/sass-lint/issues/625)
* Fixed an issue with `no-color-literals` incorrectly flagging variable names and map identifiers that shared their names with color literals [#538](https://github.com/sasstools/sass-lint/issues/538)
* CLI examples corrected thanks to [alxndr](https://github.com/alxndr) - [#649](https://github.com/sasstools/sass-lint/issues/649)

**Changes**
* `no-color-literals` now includes two extra options `allow-map-identifiers` and `allow-variable-identifiers` which allow you to fine tune your use of color literals in map identifiers/variables on top of the existing functionality [see the docs](https://github.com/sasstools/sass-lint/blob/develop/docs/rules/no-color-literals.md)
* Updated to `gonzales-pe-sl` v3.2.8

## v1.6.2

**April 22, 2016**
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Node-only Sass linter for both `sass` and `scss` syntax!
---

## Install
You can get `sass-lint` from [NPM](https://www.npmjs.com/package/sass-lint)
You can get `sass-lint` from [NPM](https://www.npmjs.com/package/sass-lint):

```
npm install sass-lint --save-dev
Expand All @@ -15,7 +15,7 @@ npm install sass-lint --save-dev

## Configuring

Sass-lint can be configured from a `.sass-lint.yml` file in your project. If you don't have one in the root of your project or you would like all your projects to follow a standard config file then you can specify the path to one in your projects `package.json` file.
Sass-lint can be configured from a `.sass-lint.yml` file in your project. If you don't have one in the root of your project or you would like all your projects to follow a standard config file then you can specify the path to one in your project's `package.json` file.

For example:
```javascript
Expand Down Expand Up @@ -90,7 +90,7 @@ With this in mind if you would like to have the CLI show both warnings and error

#### Specify a config

Below is an example of the command being used to load a config `-c app/config/.sass-lint.yml` file show errors and warnings on the command line and target a glob pattern `**/*.scss` being used.
Below is an example of the command being used to load a config `-c app/config/.sass-lint.yml` file, show errors and warnings on the command line, and target a glob pattern `**/*.scss`:

```
sass-lint -c app/config/.sass-lint.yml '**/*.scss' -v -q
Expand All @@ -105,17 +105,17 @@ sass-lint --config app/config/.sass-lint.yml '**/*.scss' --verbose --no-exit
#### Ignore files/patterns
To add a list of files to ignore `tests/**/*.scss, dist/other.scss` into the mix you could do the following:
```
sass-lint -c app/config/.sass-lint.yml '**/*.scss' -v -q -i 'tests/**/*.scss'
sass-lint -c app/config/.sass-lint.yml '**/*.scss' -v -q -i 'tests/**/*.scss, dist/other.scss'
```
or with long form flags
```
sass-lint --config app/config/.sass-lint.yml '**/*.scss' --verbose --no-exit --ignore 'tests/**/*.scss, dist/other.scss'
```
> Notice that glob patterns need to be wrapped in quotation or single quote marks in order to be passed to sass-lint correctly and if you want to ignore multiple paths you also need to wrap it in quotation marks and seperate each pattern/fil with a comma and a space `, `.
> Notice that glob patterns need to be wrapped in quotation or single quote marks in order to be passed to sass-lint correctly and if you want to ignore multiple paths you also need to wrap it in quotation marks and seperate each pattern/file with a comma and a space `, `.
This will be revisited and updated in `sass-lint` v2.0.0
This will be revisited and updated in `sass-lint` v2.0.0.
For further information you can visit our CLI documentation linked below.
Expand Down
94 changes: 84 additions & 10 deletions docs/rules/no-color-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Other color functions, such as `adjust-color` and `mix`, may be used, but the or

## Options

* `allow-map-identifiers`: `true`/`false` (defaults to `true`)
* `allow-rgba`: `true`/`false` (defaults to `false`)
* `allow-variable-identifiers`: `true`/`false` (defaults to `true`)

## Examples

When enabled and `allow-rgba` is set to `false` the following are disallowed.
When enabled and default options are used the following are disallowed.

```scss
.literal {
Expand All @@ -39,22 +41,27 @@ When enabled and `allow-rgba` is set to `false` the following are disallowed.
color: #fff;
}

// rgb function passed directly as function argument
.adj {
color: adjust-color(rgb(255, 0, 0), $blue: 5);
}

// hsl function passed directly as function argument
.scale {
color: scale-color(hsl(120, 70%, 80%), $lightness: 50%);
}

// hsl function passed directly as function argument
.change {
color: change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: .8);
}

// color literal passed directly as function argument
.function {
color: test(#fff);
}

// color functions used directly as property values
.rgb {
color: rgb(255, 255, 255);
}
Expand All @@ -71,16 +78,9 @@ When enabled and `allow-rgba` is set to `false` the following are disallowed.
color: hsla(40, 50%, 50%, .3);
}

// using color literals as property names
$colors: (
red: #fff,
blue : (
orange: #fff
)
);
```

When enabled and `allow-rgba` is set to `false` the following are allowed.
When enabled and default options are used the following are allowed.

```scss
$literal: mediumslateblue;
Expand All @@ -90,6 +90,17 @@ $rgba: rgba(255, 255, 255, .3);
$hsl: hsl(40, 50%, 50%);
$hsla: hsla(40, 50%, 50%, .3);

// using color literals as property names
$colors: (
red: #fff,
blue : (
orange: #fff
)
);

// using color literals as variable identifiers
$black: #000;

.literal {
color: $literal;
}
Expand Down Expand Up @@ -139,7 +150,11 @@ $hsla: hsla(40, 50%, 50%, .3);
}
```

In addition, when enabled and `allow-rgba` is set to `true`, the following will be allowed:
---

## [allow-rgba: true]

When enabled and `allow-rgba` is set to `true`, the following will be allowed:

```scss
// rgba in variables is still fine
Expand All @@ -161,3 +176,62 @@ In addition, when enabled and `allow-rgba` is set to `true`, the following will
color: rgba(black, .3);
}
```

---

## [allow-variable-identifiers: false]

When enabled and `allow-variable-identifiers` is set to `false`, the following will be disallowed

```scss

// variable uses a color literal as an identifier
$black: #000

// variable using a color literal as an identifier is passed to a function
.test {
color: adjust-color($off-red, $blue: 5)
}

```

When enabled and `allow-variable-identifiers` is set to `false`, the following will be allowed

```scss

// variable not directly using a color literal as an identifier
$primary-black: #000

```

---

## [allow-map-identifiers: false]

When enabled and `allow-map-identifiers` is set to `false`, the following will be disallowed

```scss

// map identifiers red, blue and orange share their name with a
// color literal and therefore shouldn't be used
$colors: (
red: #f00,
blue: (
orange: $orange
)
)

```

When enabled and `allow-map-identifiers` is set to `false`, the following will be allowed

```scss

$colors: (
primary-red: #f00,
map-blue: (
off-orange: $orange
)
)

```
2 changes: 1 addition & 1 deletion lib/rules/empty-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var helpers = require('../helpers');

module.exports = {
'name': 'no-empty-args',
'name': 'empty-args',
'defaults': {
'include': false
},
Expand Down
30 changes: 20 additions & 10 deletions lib/rules/final-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,39 @@

var helpers = require('../helpers');

/**
* Get the 'last' node of the tree to test for an EOL
*
* @param {Object} node - The node whose last child we want to return
* @returns {Object} The last node
*/
var getLastNode = function (node) {
var last = node.last();

return last ? getLastNode(last) : node;
};

module.exports = {
'name': 'final-newline',
'defaults': {
'include': true
},
'detect': function (ast, parser) {
var result = [],
last = ast.content[ast.content.length - 1],
last,
error = {
'ruleId': parser.rule.name,
'severity': parser.severity
};

// If the syntax is Sass we must recursively loop to determine the last node.
// This is not required for SCSS which will always use the last node in the
// content of the parent stylesheet node
if (ast.syntax === 'sass') {
if (typeof last.last('block') === 'object') {
var lastBlock = last.last('block');

if (lastBlock && lastBlock.content.length > 0) {
if (lastBlock.content[lastBlock.length - 1]) {
last = lastBlock.content[lastBlock.length - 1];
}
}
}
last = getLastNode(ast);
}
else {
last = ast.content[ast.content.length - 1];
}

if (!last.is('space') && !last.is('declarationDelimiter')) {
Expand Down
Loading

0 comments on commit e364a25

Please sign in to comment.