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

@linthtml/gulp-linthtml

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linthtml/gulp-linthtml - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

42

.eslintrc.js
module.exports = {
"env": {
"es6": true,
"node": true
'env': {
'es6': true,
'node': true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
'extends': 'eslint:recommended',
'globals': {
'Atomics': 'readonly',
'SharedArrayBuffer': 'readonly'
},
"parserOptions": {
"ecmaVersion": 2018
'parserOptions': {
'ecmaVersion': 2018
},
"rules": {
"indent": [
"error",
'rules': {
'indent': [
'error',
2
],
"linebreak-style": [
"error",
"unix"
'linebreak-style': [
'error',
'unix'
],
"quotes": [
"error",
"single"
'quotes': [
'error',
'single'
],
"semi": [
"error",
"always"
'semi': [
'error',
'always'
]
}
};
# Changelog
## 0.5.0
* [FEAT] Upgrade to @linthtml/linthtml@0.5.x
## 0.4.0

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

@@ -7,7 +7,4 @@ const { Transform } = require('stream');

const chalk = require('chalk');
const { cosmiconfigSync } = require('cosmiconfig');
const Table = require('table-layout');
const path = require('path');
const fs = require('fs');
const Table = require('table-layout');
const PLUGIN_NAME = 'gulp-linthtml';

@@ -28,5 +25,5 @@

function printPosition(issue, maxLine, maxColumn) {
const line = issue.line.toString();
const column = issue.column.toString();
function print_position({ position: { start } }, maxLine, maxColumn) {
const line = start.line.toString();
const column = start.column.toString();
return `${line.padStart(maxLine, ' ')}:${column.padEnd(maxColumn, ' ')}`;

@@ -42,2 +39,13 @@ }

function print_error(error) {
if (error.code) {
const ctx = new chalk.Instance({level: 0});
const [type, code] = error.code.split('-');
const error_message = linthtml.messages[`${type}_ERRORS`][code];
return error_message(ctx, error.meta);
}
return error.message;
}
/**

@@ -57,3 +65,3 @@ * Output a report

const msg = linthtml.messages.renderIssue(issue);
const positionTxt = printPosition(issue, maxLine, maxColumn);
const positionTxt = print_position(issue, maxLine, maxColumn);
const level = printLevel(issue);

@@ -102,3 +110,3 @@ issues.push({

/**
* @param {(Strint|GulpLintHTMLOptions)} [options] - Rules to convert
* @param {(String|GulpLintHTMLOptions)} [options] - Rules to convert
* @returns {Object} converted options

@@ -124,38 +132,4 @@ */

function gulpLintHTML(options) {
const explorer = cosmiconfigSync('linthtml', { stopDir: process.cwd(), packageProp: 'linthtmlConfig'});
options = convertOptions(options);
return transform((file, enc, cb) => {
let config = null;
if (options.configFile) {
const configPath = path.join(process.cwd(), options.configFile);
let isConfigDirectory = false;
try {
isConfigDirectory = fs.lstatSync(configPath).isDirectory();
if (isConfigDirectory) {
config = cosmiconfigSync('linthtml', { stopDir: configPath, packageProp: 'linthtmlConfig' }).search(configPath);
} else {
config = explorer.load(configPath);
}
if (config === null) {
throw new Error();
}
} catch (error) {
if (isConfigDirectory) {
return cb(new PluginError(PLUGIN_NAME, `gulp-linthtml cannot read config file in directory '${configPath}'`));
} else {
return cb(new PluginError(PLUGIN_NAME, `gulp-linthtml cannot read config file '${configPath}'`));
}
}
}
if (config === undefined || config === null) {
config = explorer.search();
}
if (config) {
options.rules = config.config? config.config : config;
}
if (file.isNull()) {

@@ -168,3 +142,16 @@ return cb(null, file);

}
getLintReport(file, options, cb);
let linter = null;
try {
if (options.configFile) {
linter = linthtml.from_config_path(options.configFile);
} else if (options.rules) {
linter = linthtml.fromConfig(options);
} else {
linter = linthtml.create_linters_for_files([path.relative(process.cwd(), file.path)]);
linter = linter[0] ? linter[0].linter : null;
}
} catch (error) {
return cb(new PluginError(PLUGIN_NAME, `gulp-linthtml - ${print_error(error)}`));
}
return getLintReport(file, linter, /*options */ cb);
});

@@ -178,7 +165,6 @@ }

*/
function getLintReport(file, options, cb) {
function getLintReport(file, linter, /*options,*/ cb) {
try {
let p = linthtml(file.contents.toString(), options.rules);
let p = linter.lint(file.contents.toString());
p.catch(e => cb(new PluginError(PLUGIN_NAME, e)));
p.then(reports => file.linthtml = reports)

@@ -255,3 +241,3 @@ .then(() => cb(null, file));

message: linthtml.messages.renderIssue(error),
lineNumber: error.line
lineNumber: error.position.start.line
}));

@@ -258,0 +244,0 @@ }

{
"name": "@linthtml/gulp-linthtml",
"version": "0.4.0",
"version": "0.5.0",
"description": "A gulp plugin for processing files with LintHTML",

@@ -27,5 +27,4 @@ "main": "index.js",

"dependencies": {
"@linthtml/linthtml": "0.4.x",
"chalk": "3.0.0",
"cosmiconfig": "^6.0.0",
"@linthtml/linthtml": "0.5.x",
"chalk": "4.1.0",
"fancy-log": "1.3.3",

@@ -37,7 +36,7 @@ "plugin-error": "1.0.1",

"chai": "4.2.0",
"eslint": "6.8.0",
"eslint": "7.9.0",
"from2-string": "1.1.0",
"mocha": "8.0.1",
"mocha": "8.1.3",
"vinyl": "2.2.0"
}
}

@@ -57,4 +57,3 @@ /* global describe, it*/

expect(report).to.have.property('rule');
expect(report).to.have.property('line');
expect(report).to.have.property('column');
expect(report).to.have.property('position');
// .and.have.property('ruleId', 'strict');

@@ -61,0 +60,0 @@

@@ -59,4 +59,3 @@ /* global describe, it*/

expect(report).to.have.property('rule');
expect(report).to.have.property('line');
expect(report).to.have.property('column');
expect(report).to.have.property('position');
// .and.have.property('ruleId', 'strict');

@@ -89,4 +88,3 @@

expect(report).to.have.property('rule');
expect(report).to.have.property('line');
expect(report).to.have.property('column');
expect(report).to.have.property('position');
// .and.have.property('ruleId', 'strict');

@@ -119,4 +117,3 @@

expect(report).to.have.property('rule');
expect(report).to.have.property('line');
expect(report).to.have.property('column');
expect(report).to.have.property('position');
// .and.have.property('ruleId', 'strict');

@@ -151,4 +148,3 @@

expect(report).to.have.property('rule');
expect(report).to.have.property('line');
expect(report).to.have.property('column');
expect(report).to.have.property('position');
// .and.have.property('ruleId', 'strict');

@@ -196,3 +192,3 @@

expect(err.plugin).to.equal('gulp-linthtml');
expect(err.message).to.equal(`gulp-linthtml cannot read config file '${path.resolve(__dirname, 'fixtures/config.js')}'`);
expect(err.message).to.equal(`gulp-linthtml - Error: Cannot find the config file ${path.resolve(__dirname, 'fixtures/config.js')}`);
done();

@@ -210,3 +206,3 @@ })

expect(err.plugin).to.equal('gulp-linthtml');
expect(err.message).to.equal('Configuration for rule "html-req-lang" is invalid: Expected boolean got string');
expect(err.message).to.equal('Configuration for rule "html-req-lang" is invalid: Expected boolean got string.');
done();

@@ -213,0 +209,0 @@ })

Sorry, the diff of this file is not supported yet

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