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

eslint-plugin-impress

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-impress - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

.travis.yml

12

package.json
{
"name": "eslint-plugin-impress",
"version": "2.1.0",
"version": "2.2.0",
"description": "ESLint plugin for compatibility with Impress Application Server",

@@ -28,12 +28,12 @@ "main": "plugin.js",

"devDependencies": {
"eslint": "^4.6.1",
"eslint-config-metarhia": "^1.0.0",
"eslint-plugin-import": "^2.7.0"
"eslint": "^5.9.0",
"eslint-config-metarhia": "^6.0.0",
"eslint-plugin-import": "^2.14.0"
},
"peerDependencies": {
"eslint": ">=3.17.0 <5.0.0"
"eslint": ">=3.17.0"
},
"engines": {
"node:": ">=6.0.0"
"node": ">=6.0.0"
}
}

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

const processor = {};
const processor = {
supportsAutofix: true,
};
plugin.processors = {

@@ -21,11 +23,10 @@ '.js': processor,

const MODULE_EXPORTS = 'module.exports = ';
const USE_STRICT = '\'use strict\'; ';
const USE_STRICT = '\'use strict\';\n';
const modifiedFiles = new Set();
const modifiedFiles = new Map();
processor.preprocess = (text, filename) => {
const knownPath = CONFIG_REGEX.test(filename) ||
APP_SCRIPT_REGEX.test(filename);
if (!knownPath) {
const extractedPath = CONFIG_REGEX.exec(filename) ||
APP_SCRIPT_REGEX.exec(filename);
if (!extractedPath) {
return [text];

@@ -43,11 +44,23 @@ }

const isConfig = text.startsWith('{') || text.startsWith('[');
const isHandler = text.startsWith('(') || text.startsWith('function');
if (text.endsWith(';')) {
text = text.slice(0, -1);
}
if (isConfig || isHandler) {
text = MODULE_EXPORTS + text + ';';
const trimmedText = text.trim();
const isObj = trimmedText.startsWith('{') && trimmedText.endsWith('}');
const isArr = trimmedText.startsWith('[') && trimmedText.endsWith(']');
const isApi = extractedPath[1] === 'api';
let prefixLen = USE_STRICT.length;
if (isObj) {
text = `(${text});`;
prefixLen++;
}
if (isArr || isApi) {
text += ';';
}
text = USE_STRICT + text + trail;
modifiedFiles.add(filename);
modifiedFiles.set(filename, { isObj, prefixLen });
return [text];

@@ -65,13 +78,25 @@ };

const firstMsg = messages[0];
const isFirstLineOverflown = firstMsg.ruleId === 'max-len' &&
firstMsg.line === 1;
const isUseStrictAdded = firstMsg.source.startsWith(USE_STRICT) &&
modifiedFiles.has(filename);
// TODO(aqrln): respect user's max-len rule settings
const inducedOverflow = firstMsg.source.slice(USE_STRICT.length).length <= 80;
if (isFirstLineOverflown && isUseStrictAdded && inducedOverflow) {
messages.shift();
const modifications = modifiedFiles.get(filename);
if (modifications) {
const { isObj, prefixLen } = modifications;
messages.forEach(message => {
if (message.line === 1) return;
message.line--;
if (isObj && message.line === 1 && message.column !== 1) {
message.column--;
}
if (message.fix && message.fix.range) {
if (
message.fix.range[0] > prefixLen && message.fix.range[1] > prefixLen
) {
message.fix.range[0] -= prefixLen;
message.fix.range[1] -= prefixLen;
} else {
delete message.fix;
}
}
});
}
return messages;
};
# eslint-plugin-impress
[![Build Status](https://travis-ci.org/metarhia/eslint-plugin-impress.svg?branch=master)](https://travis-ci.org/metarhia/eslint-plugin-impress)
[![Greenkeeper badge](https://badges.greenkeeper.io/metarhia/eslint-plugin-impress.svg)](https://greenkeeper.io/)
[ESLint](http://eslint.org) plugin for

@@ -4,0 +7,0 @@ [Impress Application Server](https://github.com/metarhia/Impress)

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