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

stylelint-prettier

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylelint-prettier - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

4

CHANGELOG.md
# Changelog
## 1.0.6 (2019-01-05)
- Report unparsable code as linting issues instead of crashing (#14)
## 1.0.5 (2018-11-16)

@@ -4,0 +8,0 @@

4

package.json
{
"name": "stylelint-prettier",
"version": "1.0.5",
"version": "1.0.6",
"description": "Runs prettier as an stylelint rule",

@@ -44,3 +44,3 @@ "keywords": [

"prettier": "^1.13.7",
"stylelint": "^9.2.1",
"stylelint": "^9.5.0",
"stylelint-config-prettier": "^4.0.0"

@@ -47,0 +47,0 @@ },

@@ -77,4 +77,33 @@ const stylelint = require('stylelint');

);
const prettierSource = prettier.format(source, prettierOptions);
try {
prettierSource = prettier.format(source, prettierOptions);
} catch (err) {
if (!(err instanceof SyntaxError)) {
throw err;
}
let message = 'Parsing error: ' + err.message;
// Prettier's message contains a codeframe style preview of the
// invalid code and the line/column at which the error occured.
// ESLint shows those pieces of information elsewhere already so
// remove them from the message
if (err.codeFrame) {
message = message.replace(`\n${err.codeFrame}`, '');
}
if (err.loc) {
message = message.replace(/ \(\d+:\d+\)$/, '');
}
stylelint.utils.report({
ruleName,
result,
message,
node: root,
index: getIndexFromLoc(source, err.loc.start),
});
return;
}
// Everything is the same. Nothing to do here;

@@ -178,3 +207,22 @@ if (source === prettierSource) {

function getIndexFromLoc(source, {line, column}) {
function nthIndex(str, searchValue, n) {
let i = -1;
while (n-- && i++ < str.length) {
i = str.indexOf(searchValue, i);
if (i < 0) {
break;
}
}
return i;
}
if (line === 1) {
return column - 1;
}
return nthIndex(source, '\n', line - 1) + column;
}
module.exports.ruleName = ruleName;
module.exports.messages = messages;
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