Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Chore: Makefile tweaks (#522)
Browse files Browse the repository at this point in the history
Simplify Jest calls, reorder some code to avoid lint disabling, and add check for unused disable comments
  • Loading branch information
platinumazure authored and JamesHenry committed Sep 30, 2018
1 parent bedcd10 commit 655359f
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ const OPEN_SOURCE_LICENSES = [
/MIT/, /BSD/, /Apache/, /ISC/, /WTF/, /Public Domain/
];

//------------------------------------------------------------------------------
// Data
//------------------------------------------------------------------------------

const NODE_MODULES = "./node_modules/",

// Utilities - intentional extra space at the end of each string
JEST = `${NODE_MODULES}jest/bin/jest.js`,

// Files
MAKEFILE = "./Makefile.js",
/* eslint-disable no-use-before-define */
JS_FILES = "parser.js",
TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" "),
TOOLS_FILES = find("tools/").filter(fileType("js")).join(" ");
/* eslint-enable no-use-before-define */

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
Expand All @@ -59,6 +42,19 @@ function fileType(extension) {
};
}

//------------------------------------------------------------------------------
// Data
//------------------------------------------------------------------------------

const JEST = "jest",
LINT_OPTIONS = "--report-unused-disable-directives",

// Files
MAKEFILE = "./Makefile.js",
JS_FILES = "parser.js",
TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" "),
TOOLS_FILES = find("tools/").filter(fileType("js")).join(" ");

//------------------------------------------------------------------------------
// Tasks
//------------------------------------------------------------------------------
Expand All @@ -72,25 +68,25 @@ target.lint = function() {
lastReturn;

echo("Validating Makefile.js");
lastReturn = nodeCLI.exec("eslint", MAKEFILE);
lastReturn = nodeCLI.exec("eslint", MAKEFILE, LINT_OPTIONS);
if (lastReturn.code !== 0) {
errors++;
}

echo("Validating JavaScript files");
lastReturn = nodeCLI.exec("eslint", JS_FILES);
lastReturn = nodeCLI.exec("eslint", JS_FILES, LINT_OPTIONS);
if (lastReturn.code !== 0) {
errors++;
}

echo("Validating JavaScript test files");
lastReturn = nodeCLI.exec("eslint", TEST_FILES);
lastReturn = nodeCLI.exec("eslint", TEST_FILES, LINT_OPTIONS);
if (lastReturn.code !== 0) {
errors++;
}

echo("Validating JavaScript tools files");
lastReturn = nodeCLI.exec("eslint", TOOLS_FILES);
lastReturn = nodeCLI.exec("eslint", TOOLS_FILES, LINT_OPTIONS);
if (lastReturn.code !== 0) {
errors++;
}
Expand Down

0 comments on commit 655359f

Please sign in to comment.