@ampproject/toolbox-linter
Advanced tools
Comparing version 2.5.0 to 2.5.1
import { LintMode } from "."; | ||
export declare function cli(argv: string[], logger?: Console, cmd?: string): Promise<string | void>; | ||
export declare function easyLint({ url, userAgent, format, force, headers, }: { | ||
export declare function easyLint({ url, userAgent, format, force, headers, showPassing, }: { | ||
url: string; | ||
@@ -11,2 +11,3 @@ userAgent: string; | ||
}; | ||
showPassing: boolean; | ||
}): Promise<string>; |
@@ -43,2 +43,3 @@ "use strict"; | ||
.option(`-A, --user-agent <string>`, "user agent string", /^(googlebot_desktop|googlebot_mobile|chrome_desktop|chrome_mobile)$/i, "googlebot_mobile") | ||
.option(`-s, --show-passing`, "show passing tests in output", false) | ||
.on("--help", function () { | ||
@@ -99,3 +100,3 @@ logger.log(""); | ||
exports.cli = cli; | ||
async function easyLint({ url, userAgent, format, force, headers, }) { | ||
async function easyLint({ url, userAgent, format, force, headers, showPassing, }) { | ||
headers["user-agent"] = UA[userAgent]; | ||
@@ -125,3 +126,3 @@ const raw = await (async () => { | ||
const mode = force === "auto" ? _1.guessMode($) : force; | ||
return printer(format, await _1.lint({ | ||
return printer(format, showPassing, await _1.lint({ | ||
raw, | ||
@@ -148,3 +149,3 @@ $, | ||
} | ||
function printer(type, data) { | ||
function printer(type, showPassing, data) { | ||
function flatten(data) { | ||
@@ -195,5 +196,12 @@ const rows = []; | ||
.splice(1) | ||
.map((l) => l[3] === "" | ||
? `${colorStatus(l[2])} ${l[1]}\n` | ||
: `${colorStatus(l[2])} ${l[1]}\n> ${l[3]}\n`) | ||
.sort((a, b) => _1.StatusNumber[a[2]] - | ||
_1.StatusNumber[b[2]]) | ||
.map((l) => { | ||
return l[3] !== "" | ||
? `${colorStatus(l[2])} ${l[1]}\n> ${l[3]}\n` | ||
: showPassing | ||
? `${colorStatus(l[2])} ${l[1]}\n` | ||
: ""; | ||
}) | ||
.filter((line) => line.length > 0) | ||
.join("\n"); | ||
@@ -200,0 +208,0 @@ } |
@@ -17,2 +17,9 @@ /// <reference types="cheerio" /> | ||
} | ||
export declare enum StatusNumber { | ||
PASS = 0, | ||
FAIL = 1, | ||
WARN = 2, | ||
INFO = 3, | ||
INTERNAL_ERROR = 4 | ||
} | ||
export interface Result { | ||
@@ -19,0 +26,0 @@ readonly status: Status; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cli = exports.lint = exports.guessMode = exports.Status = exports.LintMode = void 0; | ||
exports.cli = exports.lint = exports.guessMode = exports.StatusNumber = exports.Status = exports.LintMode = void 0; | ||
const cli_1 = require("./cli"); | ||
@@ -45,2 +45,10 @@ Object.defineProperty(exports, "cli", { enumerable: true, get: function () { return cli_1.cli; } }); | ||
})(Status = exports.Status || (exports.Status = {})); | ||
var StatusNumber; | ||
(function (StatusNumber) { | ||
StatusNumber[StatusNumber["PASS"] = 0] = "PASS"; | ||
StatusNumber[StatusNumber["FAIL"] = 1] = "FAIL"; | ||
StatusNumber[StatusNumber["WARN"] = 2] = "WARN"; | ||
StatusNumber[StatusNumber["INFO"] = 3] = "INFO"; | ||
StatusNumber[StatusNumber["INTERNAL_ERROR"] = 4] = "INTERNAL_ERROR"; | ||
})(StatusNumber = exports.StatusNumber || (exports.StatusNumber = {})); | ||
function guessMode($) { | ||
@@ -47,0 +55,0 @@ if ($("body amp-story[standalone]").length === 1) { |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ImagesHaveAltText = void 0; | ||
const rule_1 = require("../rule"); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
class ImagesHaveAltText extends rule_1.Rule { | ||
@@ -9,2 +13,5 @@ run({ $ }) { | ||
let output = ""; | ||
const color = (s) => { | ||
return chalk_1.default.yellow(s); | ||
}; | ||
$("amp-img").each(function (i, elem) { | ||
@@ -22,3 +29,3 @@ if (!elem.attribs.alt) { | ||
imgsWithoutAlt[key] > 1 | ||
? (output += key + " (used " + imgsWithoutAlt[key] + " times)\n") | ||
? (output += key + color(" [used " + imgsWithoutAlt[key] + " times]\n")) | ||
: (output += key + "\n"); | ||
@@ -25,0 +32,0 @@ } |
{ | ||
"name": "@ampproject/toolbox-linter", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "A linter for AMP documents", | ||
@@ -14,3 +14,3 @@ "repository": { | ||
"dependencies": { | ||
"@ampproject/toolbox-cache-list": "^2.5.0", | ||
"@ampproject/toolbox-cache-list": "^2.5.1", | ||
"@ampproject/toolbox-cache-url": "^2.3.0", | ||
@@ -45,8 +45,8 @@ "amphtml-validator": "1.0.31", | ||
}, | ||
"gitHead": "c26612cc3d7408fdc1451bcc8e0fecd67ac9661d", | ||
"gitHead": "f92ba13281ecf3e624ee8285f2deebee18d580bd", | ||
"devDependencies": { | ||
"prettier": "2.0.5", | ||
"tap-parser": "10.0.1", | ||
"typescript": "3.9.3" | ||
"typescript": "3.9.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318659
5139