Permalink
Browse files

Breaking: remove special exception for linting empty files (fixes #9534

…) (#10013)
  • Loading branch information...
not-an-aardvark committed Mar 22, 2018
1 parent 27e3f24 commit 91ece32ac5e81ea2314e0d51f885874ea5631f1f
Showing with 15 additions and 29 deletions.
  1. +0 −21 conf/blank-script.json
  2. +0 −8 lib/linter.js
  3. +15 −0 tests/lib/linter.js
View

This file was deleted.

Oops, something went wrong.
View
@@ -13,7 +13,6 @@ const eslintScope = require("eslint-scope"),
evk = require("eslint-visitor-keys"),
levn = require("levn"),
lodash = require("lodash"),
blankScriptAST = require("../conf/blank-script.json"),
CodePathAnalyzer = require("./code-path-analysis/code-path-analyzer"),
ConfigOps = require("./config/config-ops"),
validator = require("./config/config-validator"),
@@ -942,13 +941,6 @@ module.exports = class Linter {
const settings = config.settings || {};
if (!lastSourceCodes.get(this)) {
// there's no input, just exit here
if (text.trim().length === 0) {
lastSourceCodes.set(this, new SourceCode(text, blankScriptAST));
return [];
}
const parseResult = parse(
text,
parserOptions,
View
@@ -2803,6 +2803,21 @@ describe("Linter", () => {
});
});
describe("when evaluating an empty string", () => {
it("runs rules", () => {
linter.defineRule("no-programs", context => ({
Program(node) {
context.report({ node, message: "No programs allowed." });
}
}));
assert.strictEqual(
linter.verify("", { rules: { "no-programs": "error" } }).length,
1
);
});
});
describe("when evaluating code without comments to environment", () => {
it("should report a violation when using typed array", () => {
const code = "var array = new Uint8Array();";

0 comments on commit 91ece32

Please sign in to comment.