Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Upgrade: levn@0.4.1 (fixes #9366) (#13140)
* Upgrade: levn@0.4.1 (fixes #9366)

* Use String.raw to improve readability of tests

* Address feedback

* Update optionator@0.9.1
  • Loading branch information
kaicataldo committed Apr 7, 2020
1 parent c41de38 commit 95e1c70
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -69,11 +69,11 @@
"is-glob": "^4.0.0",
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
"levn": "^0.4.1",
"lodash": "^4.17.14",
"minimatch": "^3.0.4",
"natural-compare": "^1.4.0",
"optionator": "^0.8.3",
"optionator": "^0.9.1",
"progress": "^2.0.0",
"regexpp": "^3.0.0",
"semver": "^7.1.1",
Expand Down
34 changes: 32 additions & 2 deletions tests/lib/linter/linter.js
Expand Up @@ -2733,18 +2733,48 @@ describe("Linter", () => {
});

describe("when evaluating code with comments which have colon in its value", () => {
const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-\"}] */\nalert('test');";
const code = String.raw`
/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: "data:image\\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-"}] */
alert('test');
`;

it("should not parse errors, should report a violation", () => {
const messages = linter.verify(code, {}, filename);

assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, "max-len");
assert.strictEqual(messages[0].message, "This line has a length of 122. Maximum allowed is 100.");
assert.strictEqual(messages[0].message, "This line has a length of 129. Maximum allowed is 100.");
assert.include(messages[0].nodeType, "Program");
});
});

describe("when evaluating code with comments that contain escape sequences", () => {
const code = String.raw`
/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\(" }] */
console.log("test");
consolexlog("test2");
var a = "test2";
`;

it("should validate correctly", () => {
const config = { rules: {} };
const messages = linter.verify(code, config, filename);
const [message1, message2] = messages;

assert.strictEqual(messages.length, 2);
assert.strictEqual(message1.ruleId, "max-len");
assert.strictEqual(message1.message, "This line has a length of 21. Maximum allowed is 1.");
assert.strictEqual(message1.line, 4);
assert.strictEqual(message1.column, 1);
assert.include(message1.nodeType, "Program");
assert.strictEqual(message2.ruleId, "max-len");
assert.strictEqual(message2.message, "This line has a length of 16. Maximum allowed is 1.");
assert.strictEqual(message2.line, 5);
assert.strictEqual(message2.column, 1);
assert.include(message2.nodeType, "Program");
});
});

describe("when evaluating a file with a shebang", () => {
const code = "#!bin/program\n\nvar foo;;";

Expand Down

0 comments on commit 95e1c70

Please sign in to comment.