Socket
Socket
Sign inDemoInstall

eslint-plugin-microtemplates

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

CHANGELOG.md

21

lib/extract.js

@@ -23,3 +23,3 @@ /**

module.exports = function(text) {
module.exports = function (text) {
var matcher = RegExp([

@@ -47,7 +47,8 @@ delimiters.escape.source,

"\u2029": "u2029"
},
escapeChar = function(match) {
return "\\" + escapes[match];
};
function escapeChar(match) {
return "\\" + escapes[match];
}
function processTextBeforeDelimiter(match, offset) {

@@ -97,5 +98,7 @@ // Get text before the delimiter we just matched on and make it

text.replace(matcher, function(fullMatch, escape, interpolate, evaluate, offset) {
text.replace(matcher, function (fullMatch, escape, interpolate, evaluate, offset) {
var newLines,
matchedCode = escape || interpolate || evaluate;
matchedCode = escape || interpolate || evaluate,
trimmedCode = matchedCode && matchedCode.trim(),
trimOffset = matchedCode && matchedCode.indexOf(trimmedCode);

@@ -112,6 +115,7 @@ processTextBeforeDelimiter(fullMatch, offset);

lines.push({
code: "print(" + matchedCode + "); // eslint-disable-line semi\n",
code: "print(" + trimmedCode + "); // eslint-disable-line semi\n",
originalLine: currentRawLine,
originalColumn: currentRawColumn + fullMatch.indexOf(matchedCode),
cookedOffset: 6, // length of "print("
trimOffset: trimOffset,
line: currentOutputLine,

@@ -122,6 +126,7 @@ range: currentOutputIndex

lines.push({
code: matchedCode + "\n",
code: trimmedCode + "\n",
originalLine: currentRawLine,
originalColumn: currentRawColumn + fullMatch.indexOf(matchedCode),
cookedOffset: 0,
trimOffset: trimOffset,
line: currentOutputLine,

@@ -128,0 +133,0 @@ range: currentOutputIndex

@@ -34,3 +34,3 @@ /**

*/
preprocess: function(text) {
preprocess: function (text) {
currentFileLines = extract(text);

@@ -50,3 +50,3 @@

*/
postprocess: function(messages) {
postprocess: function (messages) {
assert.strictEqual(messages.length, 1);

@@ -74,3 +74,8 @@ assert(Array.isArray(messages[0]));

message.column += matchingLineInfo.originalColumn - 1;
// Cooked offset: We added text (e.g., "print(")
message.column -= matchingLineInfo.cookedOffset;
// Trim offset: We removed leading whitespace
message.column += matchingLineInfo.trimOffset;
}

@@ -77,0 +82,0 @@ }

{
"name": "eslint-plugin-microtemplates",
"version": "0.1.0",
"version": "0.2.0",
"description": "ESLint plugin for linting Resig-style microtemplate strings.",

@@ -30,5 +30,5 @@ "keywords": [

"devDependencies": {
"chai": "^3.4.1",
"eslint": "^1.10.3",
"mocha": "^2.3.4"
"chai": "^3.5.0",
"eslint": "^2.3.0",
"mocha": "^2.4.5"
},

@@ -35,0 +35,0 @@ "engines": {

# eslint-plugin-microtemplates
[![Build Status](https://travis-ci.org/platinumazure/eslint-plugin-microtemplates.svg?branch=master)](https://travis-ci.org/platinumazure/eslint-plugin-microtemplates)
[![npm](https://img.shields.io/npm/v/eslint-plugin-microtemplates.svg)](https://www.npmjs.com/package/eslint-plugin-microtemplates)
[![npm](https://img.shields.io/npm/dm/eslint-plugin-microtemplates.svg)](https://www.npmjs.com/package/eslint-plugin-microtemplates)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![Join the chat at https://gitter.im/platinumazure/eslint-plugin-microtemplates](https://badges.gitter.im/platinumazure/eslint-plugin-microtemplates.svg)](https://gitter.im/platinumazure/eslint-plugin-microtemplates?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -8,6 +11,2 @@

**Note**: This plugin is not yet ready for general consumption, and so cannot
be found on NPM. You may consume this plugin if you like by using a GitHub URL,
but you do so at your own risk!
## Installation

@@ -31,2 +30,4 @@

### Basic Configuration
Add `microtemplates` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:

@@ -42,5 +43,32 @@

You should also ensure ESLint will process HTML files. This can be done on the cli or in the CLIEngine API.
CLI:
```shell
$> eslint --ext .js,.htm,.html <options> <paths>
```
CLIEngine:
```js
var CLIEngine = require("eslint").CLIEngine;
var engine = new CLIEngine({
extensions: [".js", ".htm", ".html"],
// etc.
});
```
## Avoiding False Positives
You will want to configure ESLint to avoid common false positives. This might mean creating a separate config file for microtemplate use.
Here are some rules that may be worth disabling for microtemplates:
```json
{
"rules": {
"no-undef": 0
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc