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

lesshint

Package Overview
Dependencies
Maintainers
2
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 6.0.0 to 6.1.0

test/specs/utils/has-quotes.js

6

CHANGELOG.md
# Changelog
## 6.1.0 (2018-12-22)
* Added an `avoidEscape` option to `stringQuotes`. ([96b3ce4050aeb2695dfb5c55a52a3c613d907c21](https://github.com/lesshint/lesshint/commit/96b3ce4050aeb2695dfb5c55a52a3c613d907c21))
* Fixed an issue where `hasQuotes` wouldn't check the whole string for quotes. ([9cadda2](https://github.com/lesshint/lesshint/commit/9cadda28aa170c2b5379eb7396ba5d6676dab811))
* Fixed an issue where `newlineAfterBlock` would erroneously report blocks with multiple preceding single-line comments. ([dd4977d](https://github.com/lesshint/lesshint/commit/dd4977dd407e8ad475f54c810b04738a85e971bd))
* Fixed an issue where `singleLinePerProperty` would erroneously report blocks with preceding single-line comments. ([873e128](https://github.com/lesshint/lesshint/commit/873e1282275370f33c121556efd48a5b99fb81d1))
## 6.0.0 (2018-12-19)

@@ -3,0 +9,0 @@ * **Breaking** Updated `postcss-less` to `3.x`. If you're using custom linters this update might affect you. ([5588aaf](https://github.com/lesshint/lesshint/commit/5588aaf3ba4b7dc199f4c94ae8233e5b835ed7e3))

25

lib/config/defaults.json

@@ -48,7 +48,2 @@ {

"maxCharPerLine" : {
"enabled": true,
"limit" : 100
},
"hexLength": {

@@ -84,2 +79,7 @@ "enabled": true,

"maxCharPerLine" : {
"enabled": true,
"limit" : 100
},
"newlineAfterBlock": {

@@ -156,9 +156,9 @@ "enabled": true

"spaceAroundBang": {
"enabled": true,
"style": "before"
"enabled": true,
"style": "before"
},
"spaceAroundComma": {
"enabled": true,
"allowNewline": false,
"enabled": true,
"style": "after"

@@ -168,4 +168,4 @@ },

"spaceAroundOperator": {
"enabled": true,
"style": "both"
"enabled": true,
"style": "both"
},

@@ -185,2 +185,3 @@

"enabled": true,
"avoidEscape": false,
"style": "single"

@@ -217,6 +218,6 @@ },

"enabled": true,
"allowedValues": [],
"always": [],
"never": [],
"allowedValues": []
"never": []
}
}
'use strict';
const hasNewline = require('../utils/has-newline');
module.exports = {

@@ -42,2 +44,6 @@ name: 'newlineAfterBlock',

}
if (hasNewline(prev.raws.right)) {
return;
}
}

@@ -44,0 +50,0 @@

@@ -922,5 +922,6 @@ # Available linters

Option | Description
---------- | ----------
`style` | `double`, `single` (**default**)
Option | Description
------------- | ----------
`avoidEscape` | `false` (**default**), `boolean`
`style` | `double`, `single` (**default**)

@@ -941,2 +942,16 @@ ### invalid

### avoidEscape: true
```less
.foo {
content: "This doesn't warn";
}
```
### avoidEscape: false
```less
.foo {
content: "This does warn";
}
```
## trailingSemicolon

@@ -943,0 +958,0 @@ All property declarations should end with a semicolon.

@@ -47,7 +47,12 @@ 'use strict';

const validBefore = hasNewline(child.raws.before);
const childEnd = child.source.end || {};
const prevNode = child.prev();
let validBefore = hasNewline(child.raws.before);
let validAfter = isValidAfter(child, index);
if (prevNode && hasNewline(prevNode.raws.right)) {
validBefore = true;
}
// Check if the closing bracket is on the same line as the last property

@@ -54,0 +59,0 @@ if (index === node.nodes.length - 1 && childEnd.line === nodeEnd.line) {

@@ -20,2 +20,3 @@ 'use strict';

const correctQuote = config.style === 'double' ? '"' : "'";
const results = [];

@@ -26,7 +27,11 @@ let tree;

case 'atrule':
if (node.nodes) {
if (node.nodes || !hasQuotes(node.params)) {
return;
}
if (hasQuotes(node.params) && !hasQuotes(node.params, config.style)) {
if (config.avoidEscape && node.params.indexOf(correctQuote)) {
return;
}
if (!hasQuotes(node.params, config.style)) {
const column = node.raws.afterName.length +

@@ -52,2 +57,6 @@ node.source.start.column +

if (config.avoidEscape && decl.value.indexOf(correctQuote)) {
return;
}
if (!hasQuotes(decl.raws.quote, config.style)) {

@@ -73,3 +82,11 @@ const column = node.raws.between.length +

tree.walkAttributes((selector) => {
if (selector.quoted && !hasQuotes(selector.getQuotedValue(), config.style)) {
if (!selector.quoted) {
return;
}
if (config.avoidEscape && selector.value.indexOf(correctQuote)) {
return;
}
if (!hasQuotes(selector.getQuotedValue(), config.style)) {
const column = node.source.start.column +

@@ -76,0 +93,0 @@ selector.source.start.column +

@@ -5,5 +5,5 @@ 'use strict';

const styles = {
any: /^"|'/,
double: /^"/,
single: /^'/
any: /"|'/,
double: /"/,
single: /'/
};

@@ -10,0 +10,0 @@

{
"name": "lesshint",
"description": "A tool to aid you in writing clean and consistent Less.",
"version": "6.0.0",
"version": "6.1.0",
"main": "./lib/index.js",

@@ -6,0 +6,0 @@ "author": {

@@ -167,3 +167,19 @@ 'use strict';

});
it('should not report blocks with multiple preceding single-line comments', function () {
const source = `
// A comment
// Another comment
.foo {
color: red;
}
`;
return spec.parse(source, function (ast) {
const result = spec.linter.lint({}, ast.root.last);
expect(result).to.be.undefined;
});
});
});
});

@@ -393,3 +393,20 @@ 'use strict';

});
it('should not report single line comments on the line above', function () {
const source = `
.foo {
// A comment
&--bar {
color: red;
}
}
`;
return spec.parse(source, function (ast) {
const result = spec.linter.lint({}, ast.root.first);
expect(result).to.be.undefined;
});
});
});
});

@@ -6,2 +6,3 @@ 'use strict';

/* eslint-disable quotes */
describe('lesshint', function () {

@@ -420,2 +421,44 @@ describe('#stringQuotes()', function () {

it('should not warn on at-rules when "avoidEscape" is used', function () {
const source = `@import "'foo.less'"`;
const options = {
style: 'single',
avoidEscape: true
};
return spec.parse(source, function (ast) {
const result = spec.linter.lint(options, ast.root.first);
expect(result).to.deep.undefined;
});
});
it('should not warn on declarations when "avoidEscape" is used', function () {
const source = `.foo { content: "This shouldn't warn"; }`;
const options = {
style: 'single',
avoidEscape: true
};
return spec.parse(source, function (ast) {
const result = spec.linter.lint(options, ast.root.first.first);
expect(result).to.be.undefined;
});
});
it('should not warn on selectors when "avoidEscape" is used', function () {
const source = `input[bar="baz'"] {}`;
const options = {
style: 'single',
avoidEscape: true
};
return spec.parse(source, function (ast) {
const result = spec.linter.lint(options, ast.root.first);
expect(result).to.be.undefined;
});
});
it('should throw on invalid "style" value', function () {

@@ -422,0 +465,0 @@ const source = ".foo { content: 'Hello world' }";

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