Skip to content

Commit

Permalink
Breaking: refresh config logic (fixes #11510)
Browse files Browse the repository at this point in the history
- Passed tests in tests/lib/cli-engine.js
  • Loading branch information
mysticatea committed Mar 24, 2019
1 parent 78358a8 commit 99b63eb
Show file tree
Hide file tree
Showing 85 changed files with 9,662 additions and 7,934 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -1,3 +1,4 @@
/.nyc_output/**
/build/**
/coverage/**
/docs/**
Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/.nyc_output
/node_modules
test.js
coverage/
Expand Down
12 changes: 12 additions & 0 deletions .nycrc
@@ -0,0 +1,12 @@
{
"include": [
"bin/**/*.js",
"conf/**/*.js",
"lib/**/*.js"
],
"reporter": [
"lcov",
"text-summary"
],
"sourceMap": true
}
12 changes: 3 additions & 9 deletions Makefile.js
Expand Up @@ -84,12 +84,7 @@ const NODE = "node ", // intentional extra space
* @private
*/
function getTestFilePatterns() {
return ls("tests/lib/").filter(pathToCheck => test("-d", `tests/lib/${pathToCheck}`)).reduce((initialValue, currentValues) => {
if (currentValues !== "rules") {
initialValue.push(`"tests/lib/${currentValues}/**/*.js"`);
}
return initialValue;
}, ["\"tests/lib/rules/**/*.js\"", "\"tests/lib/*.js\"", "\"tests/bin/**/*.js\"", "\"tests/tools/**/*.js\""]).join(" ");
return ["\"tests/lib/**/*.js\"", "\"tests/bin/**/*.js\"", "\"tests/tools/**/*.js\""].join(" ");
}

/**
Expand Down Expand Up @@ -567,13 +562,12 @@ target.test = function() {

echo("Running unit tests");

lastReturn = exec(`${getBinFile("istanbul")} cover ${MOCHA} -- -R progress -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`);
lastReturn = exec(`${getBinFile("nyc")} -- ${MOCHA} -R progress -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`);
if (lastReturn.code !== 0) {
errors++;
}

lastReturn = exec(`${getBinFile("istanbul")} check-coverage --statement 99 --branch 98 --function 99 --lines 99`);

lastReturn = exec(`${getBinFile("nyc")} check-coverage --statement 99 --branch 98 --function 99 --lines 99`);
if (lastReturn.code !== 0) {
errors++;
}
Expand Down
30 changes: 30 additions & 0 deletions benchmark.js
@@ -0,0 +1,30 @@
"use strict";

/* eslint no-console: off */

const { CLIEngine } = require(".");

const files = ["bin", "conf", "lib", "tests", "tools", "*.js", ".*.js"];
const medians = [];

console.log(`Run engine.executeOnFiles(${JSON.stringify(files)})`);
console.log();

const times = [];

for (let i = 1; i <= 5; ++i) {
const startTime = Date.now();
const engine = new CLIEngine();
const { results } = engine.executeOnFiles(files);
const endTime = Date.now();

times.push(endTime - startTime);
console.log(`Time[${i}]: ${endTime - startTime} ms per ${results.length} files`);
}

const median = times.sort()[times.length / 2 | 0];

medians.push(median);
console.log();
console.log(`Median Time: ${median} ms`);
console.log();
4 changes: 2 additions & 2 deletions lib/api.js
Expand Up @@ -5,11 +5,11 @@

"use strict";

const Linter = require("./linter");
const { Linter } = require("./linter");

module.exports = {
Linter,
CLIEngine: require("./cli-engine"),
CLIEngine: require("./cli-engine").CLIEngine,
RuleTester: require("./testers/rule-tester"),
SourceCode: require("./util/source-code")
};
Expand Down

0 comments on commit 99b63eb

Please sign in to comment.