Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lesshint

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lesshint - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

lib/linters/duplicate_property.js

11

CHANGELOG.md
# Changelog
### 0.3.0 (2015-05-01)
* Added the following linters:
* `emptyRule`
* `finalNewline`
* `idSelector`
* `trailingSemicolon`
* `urlFormat`
* `urlQuotes`
* Better error messages, the property or value that caused the error are now more clearly described.
* Internal code cleanup.
## 0.2.0 (2015-04-27)

@@ -4,0 +15,0 @@ * Added the following linters:

@@ -7,2 +7,14 @@ {

"duplicateProperty": {
"enabled": true
},
"emptyRule": {
"enabled": true
},
"finalNewline": {
"enabled": true
},
"hexLength": {

@@ -22,2 +34,6 @@ "enabled": true,

"idSelector": {
"enabled": true
},
"spaceAfterPropertyColon": {

@@ -36,3 +52,7 @@ "enabled": true,

"style": "one_space"
},
"trailingSemicolon": {
"enabled": true
}
}

12

lib/linter.js
'use strict';
var configLoader = require('./config-loader');
var flatten = require('lodash.flatten');
var gonzales = require('gonzales-pe');

@@ -9,8 +10,13 @@ var merge = require('lodash.merge');

require('./linters/border_zero'),
require('./linters/duplicate_property'),
require('./linters/empty_rule'),
require('./linters/final_newline'),
require('./linters/hex_length'),
require('./linters/hex_notation'),
require('./linters/hex_validation'),
require('./linters/id_selector'),
require('./linters/space_after_property_colon'),
require('./linters/space_after_property_name'),
require('./linters/space_before_brace')
require('./linters/space_before_brace'),
require('./linters/trailing_semicolon')
];

@@ -38,5 +44,7 @@

// Remove empty errors
return errors.filter(function (error) {
errors = errors.filter(function (error) {
return error !== null && error !== true;
});
return flatten(errors);
};

@@ -43,0 +51,0 @@

19

lib/linters/border_zero.js
'use strict';
var find = require('lodash.find');
var path = require('path');

@@ -25,10 +24,4 @@

property = find(node.content, function (element) {
if (element.type === 'property') {
return true;
}
property = node.first('property');
return false;
});
// Not a border* property, bail

@@ -39,12 +32,6 @@ if (properties.indexOf(property.content[0].content) === -1) {

value = find(node.content, function (element) {
if (element.type === 'value') {
return true;
}
value = node.first('value');
return false;
});
// Bail if it's an actual border
if (value.content[0].content !== '0' && value.content[0].content !== 'none') {
if ((value.content[0].content !== '0' && value.content[0].content !== 'none')) {
return null;

@@ -51,0 +38,0 @@ }

'use strict';
var find = require('lodash.find');
var path = require('path');

@@ -29,9 +28,3 @@

node.forEach('value', function (element) {
value = find(element.content, function (element) {
if (element.type === 'color') {
return true;
}
return false;
});
value = element.first('color');
});

@@ -49,3 +42,3 @@

if (!/^#[0-9a-f]{6}$/i.test(color)) {
message = 'Hexadecimal colors should be written in the long-form format.';
message = color + ' should be written in the long-form format.';
}

@@ -57,3 +50,3 @@

if (!/^#[0-9a-f]{3}$/i.test(color) && canShorten(color)) {
message = 'Hexadecimal colors should be written in the short-form format.';
message = color + ' should be written in the short-form format.';
}

@@ -60,0 +53,0 @@

'use strict';
var find = require('lodash.find');
var path = require('path');

@@ -25,9 +24,3 @@

node.forEach('value', function (element) {
value = find(element.content, function (element) {
if (element.type === 'color') {
return true;
}
return false;
});
value = element.first('color');
});

@@ -45,3 +38,3 @@

if (!/^#([0-9a-f]{3}|[0-9a-f]{6})$/.test(color)) {
message = 'Hexadecimal colors should be written in lowercase.';
message = color + ' should be written in lowercase.';
}

@@ -52,3 +45,3 @@

if (!/^#([0-9A-F]{3}|[0-9A-F]{6})$/.test(color)) {
message = 'Hexadecimal colors should be written in uppercase.';
message = color + ' should be written in uppercase.';
}

@@ -55,0 +48,0 @@

'use strict';
var find = require('lodash.find');
var path = require('path');

@@ -25,9 +24,3 @@

node.forEach('value', function (element) {
value = find(element.content, function (element) {
if (element.type === 'color') {
return true;
}
return false;
});
value = element.first('color');
});

@@ -43,3 +36,3 @@

if (!/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(color)) {
message = 'Hexadecimal colors should be either three or six characters long.';
message = 'Hexadecimal color "' + color + '" should be either three or six characters long.';
}

@@ -46,0 +39,0 @@

@@ -8,8 +8,13 @@ # Available linters

* [borderZero](#borderzero)
* [duplicateProperty](#duplicateproperty)
* [emptyRule](#emptyrule)
* [finalNewline](#finalnewline)
* [hexLength](#hexlength)
* [hexNotation](#hexnotation)
* [hexValidation](#hexvalidation)
* [idSelector](#idselector)
* [spaceAfterPropertyColon](#spaceafterpropertycolon)
* [spaceAfterPropertyName](#spaceafterpropertyname)
* [spaceBeforeBrace](#spacebeforebrace)
* [trailingSemicolon](#trailingsemicolon)

@@ -37,2 +42,56 @@ ## borderZero

## duplicateProperty
There shouldn't be any duplicate properties.
### invalid
```css
.foo {
color: red;
color: blue;
}
```
### valid
```css
.foo {
color: red;
}
```
## emptyRule
There shouldn't be any empty rules present.
### invalid
```css
.foo {
}
```
### valid
```css
.foo {
color: red;
}
```
## finalNewline
All files should end with a empty line.
### invalid
```css
.foo {
color: red;
}
```
### valid
```css
.foo {
color: red;
}
...
```
## hexLength

@@ -97,2 +156,19 @@ Prefer longhand hex color declarations over short hand ones.

## idSelector
Disallow the usage of ID selectors.
### invalid
```css
#foo {
color: red;
}
```
### valid
```css
.foo {
color: red;
}
```
## spaceAfterPropertyColon

@@ -168,1 +244,18 @@ Each colon in property declarations should be followed by a space.

```
## trailingSemicolon
All property declarations should end with a semicolon.
### invalid
```css
.foo {
color: red
}
```
### valid
```css
.foo {
color: red;
}
```
{
"name": "lesshint",
"description": "A tool to aid you in writing clean and consistent Less.",
"version": "0.2.0",
"version": "0.3.0",
"main": "./lib/lesshint.js",

@@ -24,4 +24,4 @@ "author": {

"gonzales-pe": "^3.0.0-26",
"lodash.find": "^3.2.0",
"lodash.findindex": "^3.2.0",
"lodash.flatten": "^3.0.2",
"lodash.merge": "^3.2.0",

@@ -28,0 +28,0 @@ "rcfinder": "^0.1.8",

@@ -8,3 +8,3 @@ var assert = require('assert');

it('should return array of errors', function () {
var source = '.foo{ color:red; }';
var source = '.foo{ color:red; }\n';
var path = 'test.less';

@@ -11,0 +11,0 @@ var actual;

@@ -18,3 +18,3 @@ var assert = require('assert');

linter: 'hexLength',
message: 'Hexadecimal colors should be written in the long-form format.'
message: '#ABC should be written in the long-form format.'
};

@@ -71,3 +71,3 @@

linter: 'hexLength',
message: 'Hexadecimal colors should be written in the short-form format.'
message: '#AABBCC should be written in the short-form format.'
};

@@ -143,3 +143,3 @@

linter: 'hexLength',
message: 'Hexadecimal colors should be written in the short-form format.'
message: '#AABBCC should be written in the short-form format.'
};

@@ -146,0 +146,0 @@

@@ -18,3 +18,3 @@ var assert = require('assert');

linter: 'hexNotation',
message: 'Hexadecimal colors should be written in lowercase.'
message: '#AABBCC should be written in lowercase.'
};

@@ -71,3 +71,3 @@

linter: 'hexNotation',
message: 'Hexadecimal colors should be written in uppercase.'
message: '#aabbcc should be written in uppercase.'
};

@@ -123,3 +123,3 @@

linter: 'hexNotation',
message: 'Hexadecimal colors should be written in lowercase.'
message: '#AABBCC should be written in lowercase.'
};

@@ -126,0 +126,0 @@

@@ -37,3 +37,3 @@ var assert = require('assert');

linter: 'hexValidation',
message: 'Hexadecimal colors should be either three or six characters long.'
message: 'Hexadecimal color "#AABBC" should be either three or six characters long.'
};

@@ -68,3 +68,3 @@

linter: 'hexValidation',
message: 'Hexadecimal colors should be either three or six characters long.'
message: 'Hexadecimal color "#AABBC" should be either three or six characters long.'
};

@@ -71,0 +71,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc