Socket
Socket
Sign inDemoInstall

eslint-plugin-json

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-json - npm Package Compare versions

Comparing version 2.1.2 to 3.0.0

2

LICENSE.txt
The MIT License (MIT)
Copyright (c) 2015-2020 Azeem Bande-Ali
Copyright (c) 2015-2021 Azeem Bande-Ali

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

{
"name": "eslint-plugin-json",
"version": "2.1.2",
"version": "3.0.0",
"description": "eslint plugin for JSON files",

@@ -31,18 +31,18 @@ "keywords": [

"dependencies": {
"lodash": "^4.17.19",
"vscode-json-languageservice": "^3.7.0"
"lodash": "^4.17.21",
"vscode-json-languageservice": "^4.0.2"
},
"devDependencies": {
"chai": "^4.2.0",
"codecov": "^3.7.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"chai": "^4.3.4",
"codecov": "^3.8.1",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-self": "^1.2.1",
"mocha": "^7.2.0",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"prettier": "^1.19.1"
"prettier": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
"node": ">=12.0"
},

@@ -49,0 +49,0 @@ "url": "https://github.com/azeemba/eslint-plugin-json",

@@ -11,3 +11,3 @@ # eslint-plugin-json

:warning: Starting from **major 2.0**, rules **need to be explicitely activated**.
:warning: Starting from **major 2.0**, rules **need to be explicitly activated**.
[See **here** the minimal config to add](#basic-configuration) :rotating_light:

@@ -14,0 +14,0 @@

@@ -24,3 +24,3 @@ const _ = require('lodash/fp');

CommentNotPermitted: 0x209,
SchemaResolveError: 0x300
SchemaResolveError: 0x300,
};

@@ -35,3 +35,3 @@

const getSignature = problem =>
const getSignature = (problem) =>
`${problem.range.start.line} ${problem.range.start.character} ${problem.message}`;

@@ -41,3 +41,3 @@

return _.pipe(
_.map(problem => [getSignature(problem), problem]),
_.map((problem) => [getSignature(problem), problem]),
_.reverse, // reverse ensure fromPairs keep first signature occurence of problem

@@ -47,4 +47,4 @@ _.fromPairs

}
const reportError = filter => (errorName, context) => {
_.filter(filter, fileLintResults[context.getFilename()]).forEach(error => {
const reportError = (filter) => (errorName, context) => {
_.filter(filter, fileLintResults[context.getFilename()]).forEach((error) => {
context.report({

@@ -55,4 +55,4 @@ ruleId: `json/${errorName}`,

start: {line: error.range.start.line + 1, column: error.range.start.character},
end: {line: error.range.end.line + 1, column: error.range.end.character}
}
end: {line: error.range.end.line + 1, column: error.range.end.character},
},
// later: see how to add fix

@@ -66,3 +66,3 @@ });

_.forEach(comment => {
_.forEach((comment) => {
context.report({

@@ -73,4 +73,4 @@ ruleId: errorName,

start: {line: comment.start.line + 1, column: comment.start.character},
end: {line: comment.end.line + 1, column: comment.end.character}
}
end: {line: comment.end.line + 1, column: comment.end.character},
},
});

@@ -84,6 +84,6 @@ }, fileComments[context.getFilename()]);

Program() {
_.flatten([reporters]).map(reporter => reporter(errorName, context));
}
_.flatten([reporters]).map((reporter) => reporter(errorName, context));
},
};
}
},
});

@@ -98,4 +98,4 @@

errorName,
reportError(err => err.code === errorCode)
)
reportError((err) => err.code === errorCode)
),
]),

@@ -107,8 +107,8 @@ _.fromPairs,

unknown: makeRule('unknown', reportError(_.negate(AllErrorCodes.includes))),
'comment-not-permitted': makeRule('comment-not-permitted', reportComment)
'comment-not-permitted': makeRule('comment-not-permitted', reportComment),
})
)(ErrorCodes);
const errorSignature = err =>
['message', 'line', 'column', 'endLine', 'endColumn'].map(field => err[field]).join('::');
const errorSignature = (err) =>
['message', 'line', 'column', 'endLine', 'endColumn'].map((field) => err[field]).join('::');

@@ -119,3 +119,3 @@ const getErrorCode = _.pipe(_.get('ruleId'), _.split('/'), _.last);

'.json': {
preprocess: function(text, fileName) {
preprocess: function (text, fileName) {
const textDocument = jsonService.TextDocument.create(fileName, 'json', 1, text);

@@ -128,3 +128,3 @@ fileDocuments[fileName] = textDocument;

},
postprocess: function(messages, fileName) {
postprocess: function (messages, fileName) {
const textDocument = fileDocuments[fileName];

@@ -136,3 +136,3 @@ delete fileLintResults[fileName];

_.groupBy(errorSignature),
_.mapValues(errors => {
_.mapValues((errors) => {
if (errors.length === 1) return _.first(errors);

@@ -149,6 +149,6 @@ // Otherwise there is two errors: the generic and specific one

}),
_.mapValues(error => {
_.mapValues((error) => {
const source = textDocument.getText({
start: {line: error.line - 1, character: error.column},
end: {line: error.endLine - 1, character: error.endColumn}
end: {line: error.endLine - 1, character: error.endColumn},
});

@@ -158,3 +158,3 @@ return _.assign(error, {

column: error.column + 1,
endColumn: error.endColumn + 1
endColumn: error.endColumn + 1,
});

@@ -164,4 +164,4 @@ }),

)(messages);
}
}
},
},
};

@@ -173,4 +173,4 @@

rules: {
'json/*': 'error'
}
'json/*': 'error',
},
},

@@ -180,7 +180,7 @@ 'recommended-with-comments': {

rules: {
'json/*': ['error', {allowComments: true}]
}
}
'json/*': ['error', {allowComments: true}],
},
},
};
module.exports = {rules, configs, processors};
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