New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-jscs

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-jscs - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

CONTRIBUTING.md

4

acorn-to-esprima.js

@@ -76,3 +76,5 @@ var traverse = require("babel-core").traverse;

return tokens.map(exports.toToken);
return tokens.filter(function (token) {
return token.type !== "CommentLine" && token.type !== "CommentBlock";
}).map(exports.toToken);
};

@@ -79,0 +81,0 @@

var acornToEsprima = require("./acorn-to-esprima");
var parse = require("babel-core").parse;
exports.attachComments = function (ast, comments, tokens) {
if (comments.length) {
var firstComment = comments[0];
var lastComment = comments[comments.length - 1];
// fixup program start
if (!tokens.length) {
// if no tokens, the program starts at the end of the last comment
ast.range[0] = lastComment.range[1];
ast.loc.start.line = lastComment.loc.end.line;
ast.loc.start.column = lastComment.loc.end.column;
} else if (firstComment.start < tokens[0].range[0]) {
// if there are comments before the first token, the program starts at the first token
var token = tokens[0];
ast.range[0] = token.range[0];
ast.loc.start.line = token.loc.start.line;
ast.loc.start.column = token.loc.start.column;
// estraverse do not put leading comments on first node when the comment
// appear before the first token
if (ast.body.length) {
var node = ast.body[0];
node.leadingComments = [];
var firstTokenStart = token.range[0];
var len = comments.length;
for (var i = 0; i < len && comments[i].start < firstTokenStart; i++) {
node.leadingComments.push(comments[i]);
}
}
}
// fixup program end
if (tokens.length) {
var lastToken = tokens[tokens.length - 1];
if (lastComment.end > lastToken.range[1]) {
// If there is a comment after the last token, the program ends at the
// last token and not the comment
ast.range[1] = lastToken.range[1];
ast.loc.end.line = lastToken.loc.end.line;
ast.loc.end.column = lastToken.loc.end.column;
}
}
}
};
exports.parse = function (code, mode) {

@@ -38,3 +81,12 @@ var opts = {

// add comments
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
if (comment.type === "CommentBlock") {
comment.type = "Block";
} else if (comment.type === "CommentLine") {
comment.type = "Line";
}
}
ast.comments = comments;
exports.attachComments(ast, comments, ast.tokens);

@@ -41,0 +93,0 @@ // transform esprima and acorn divergent nodes

{
"name": "babel-jscs",
"version": "2.0.0",
"version": "2.0.1",
"description": "",

@@ -15,4 +15,6 @@ "main": "index.js",

"scripts": {
"bootstrap": "git submodule update --init && cd jscs && npm install",
"jscs": "cd jscs && mocha --colors",
"test": "mocha",
"lint": "./node_modules/.bin/jscs .",
"lint": "./node_modules/.bin/jscs test index.js acorn-to-esprima.js",
"travis": "npm test && npm run lint"

@@ -19,0 +21,0 @@ },

@@ -5,2 +5,4 @@ # babel-jscs [![Build Status][travis-image]][travis-url]

> ### Use version > 2.0.0: `package.json`: `"jscs": "^2.0.0"`
> Also check out the fantastic [babel-eslint](https://github.com/babel/babel-eslint) to lint using [ESLint](https://github.com/eslint/eslint).

@@ -11,3 +13,2 @@

### Known Issues
> **Only works on master right now** - `package.json`: `"jscs": "jscs-dev/node-jscs#master",`

@@ -14,0 +15,0 @@ ### Issues

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