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

prettier-plugin-apex

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-apex - npm Package Compare versions

Comparing version 1.0.0-alpha.8 to 1.0.0-alpha.9

10

CHANGELOG.md
## Unreleased
- Fix trailing comments after class names not being printed ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/20)).
- Add new lines in empty blocks for Enum.
- Add new lines to long list of annotation parameters.
- Add new lines to long list of method declaration parameters.
- Add new line after last usage parameter in long list for triggers.
- Add new lines to long list of conditions in loops.
- Fix missing alias in FROM expression ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/25)).
- Fix double quotes being escaped unnecessarily ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/24)).
- Fix inline comments in blocks being attached to wrong node ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/23)).
- Fix comments being pushed to next lines because of node's trailing empty line ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/26)).

@@ -3,0 +13,0 @@ ## 1.0.0-alpha.8

2

package.json
{
"name": "prettier-plugin-apex",
"version": "1.0.0-alpha.8",
"version": "1.0.0-alpha.9",
"description": "Salesforce Apex plugin for Prettier",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -1,2 +0,2 @@

# Prettier Apex [![Build Status](https://travis-ci.org/dangmai/prettier-plugin-apex.svg)](https://travis-ci.org/dangmai/prettier-plugin-apex)
# Prettier Apex [![Build Status](https://travis-ci.org/dangmai/prettier-plugin-apex.svg)](https://travis-ci.org/dangmai/prettier-plugin-apex) [![npm](https://img.shields.io/npm/v/prettier-plugin-apex.svg)](https://www.npmjs.com/package/prettier-plugin-apex)

@@ -3,0 +3,0 @@ ![Prettier Banner](https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-banner-light.png)

@@ -196,12 +196,14 @@ /* eslint no-param-reassign: 0, no-plusplus: 0, no-else-return: 0, consistent-return: 0 */

// eslint-disable-next-line no-cond-assign
comment = tiesToBreak[indexOfFirstLeadingComment];
while (
comment &&
indexOfFirstLeadingComment <= tieCount &&
(comment = tiesToBreak[indexOfFirstLeadingComment]) &&
// If the comment is a //-style comment and indented more
// deeply than the node itself, reconsider it as trailing.
comment["@class"] === apexNames.INLINE_COMMENT &&
comment.location.column > fn.loc.column
// If the comment is indented more deeply than the node itself, and there's
// non-whitespace characters before it on the same line, reconsider it as
// trailing.
comment.location.column > fn.loc.column &&
!/\n(\s*)$/.test(sourceCode.slice(0, comment.location.startIndex))
) {
indexOfFirstLeadingComment += 1;
comment = tiesToBreak[indexOfFirstLeadingComment];
}

@@ -323,2 +325,3 @@

const comment = commentPath.getValue(commentPath);
const parentNode = commentPath.getParentNode();
const loc = comment.location;

@@ -339,7 +342,10 @@ const parts = [];

}
// When we print trailing inline comments, we have to make sure that nothing
// else is printed after it (e.g. a semicolon), so we'll use lineSuffix
// from prettier to buffer the output
if (comment["@class"] === apexNames.INLINE_COMMENT) {
// When we print trailing inline comments, we have to make sure that nothing
// else is printed after it (e.g. a semicolon), so we'll use lineSuffix
// from prettier to buffer the output
if (leadingSpace.length > 0 && numberOfNewLines === 0) {
if (
(leadingSpace.length > 0 && numberOfNewLines === 0) ||
parentNode["@class"] === apexNames.LOCATION_IDENTIFIER
) {
parts.push(lineSuffix(concat([" ", print(commentPath)])));

@@ -382,3 +388,7 @@ } else {

}
parts.push(print(commentPath));
if (comment["@class"] === apexNames.INLINE_COMMENT) {
parts.push(lineSuffix(print(commentPath)));
} else {
parts.push(print(commentPath));
}
return concat(parts);

@@ -388,16 +398,16 @@ }

function allowTrailingComments(apexClass) {
let trailingCommentsAllowed = false;
const allowedTypes = [
apexNames.CLASS_DECLARATION,
apexNames.INTERFACE_DECLARATION,
apexNames.METHOD_DECLARATION,
apexNames.ENUM_DECLARATION,
apexNames.VARIABLE_DECLARATION,
apexNames.LOCATION_IDENTIFIER,
];
let trailingCommentsAllowed = allowedTypes.includes(apexClass);
const separatorIndex = apexClass.indexOf("$");
if (separatorIndex !== -1) {
const parentClass = apexClass.substring(0, separatorIndex);
trailingCommentsAllowed = parentClass === apexNames.STATEMENT;
} else {
const allowedTypes = [
apexNames.CLASS_DECLARATION,
apexNames.INTERFACE_DECLARATION,
apexNames.METHOD_DECLARATION,
apexNames.ENUM_DECLARATION,
apexNames.VARIABLE_DECLARATION,
];
trailingCommentsAllowed = allowedTypes.includes(apexClass);
trailingCommentsAllowed =
trailingCommentsAllowed || parentClass === apexNames.STATEMENT;
}

@@ -404,0 +414,0 @@ return trailingCommentsAllowed;

@@ -105,16 +105,14 @@ /* eslint no-param-reassign: 0 no-underscore-dangle: 0 */

});
if (
node.loc &&
currentLocation &&
node.loc.startIndex > currentLocation.startIndex
) {
node.loc.startIndex = currentLocation.startIndex;
if (node.loc && currentLocation) {
if (node.loc.startIndex > currentLocation.startIndex) {
node.loc.startIndex = currentLocation.startIndex;
} else {
currentLocation.startIndex = node.loc.startIndex;
}
if (node.loc.endIndex < currentLocation.endIndex) {
node.loc.endIndex = currentLocation.endIndex;
} else {
currentLocation.endIndex = node.loc.endIndex;
}
}
if (
node.loc &&
currentLocation &&
node.loc.endIndex < currentLocation.endIndex
) {
node.loc.endIndex = currentLocation.endIndex;
}
if (currentLocation) {

@@ -121,0 +119,0 @@ return currentLocation;

Sorry, the diff of this file is too big to display

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