Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: added fixlint in Makefile.js #440

Merged
merged 7 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const NODE_MODULES = "./node_modules/",
MAKEFILE = "Makefile.js",
CONFIG_FILES = ".eslintrc.js",
JS_FILES = "\"lib/**/*.js\" \"espree.js\"",
TEST_FILES = "tests/lib/**/*.js";
TEST_FILES = "tests/lib/**/*.js",

// FLAGS
CLIFLAGS = process.argv.slice(3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the documentation, I’m not sure nodeCLI.exec() accepts an array as an argument. Should this be the following?

Suggested change
CLIFLAGS = process.argv.slice(3);
CLIFLAGS = process.argv.slice(3).join( );

Alternatively, we could use the spread operator in the function calls below:

lastReturn = nodeCLI.exec("eslint", MAKEFILE, ...CLIFLAGS);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused as in this line it does say that the args are converted an array but here it is looping the argument.

I think its better to use the spread operator.


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

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

echo("Validating configuration files");
lastReturn = nodeCLI.exec("eslint", CONFIG_FILES);
lastReturn = nodeCLI.exec("eslint", CONFIG_FILES, CLIFLAGS);
if (lastReturn.code !== 0) {
errors++;
}

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

echo("Validating JavaScript test files");
lastReturn = nodeCLI.exec("eslint", TEST_FILES);
lastReturn = nodeCLI.exec("eslint", TEST_FILES, CLIFLAGS);
if (lastReturn.code !== 0) {
errors++;
}
Expand All @@ -80,7 +83,14 @@ target.test = function() {

let errors = 0;

const lastReturn = nodeCLI.exec("nyc", MOCHA, "--color", "--reporter progress", "--timeout 30000", TEST_FILES);
const lastReturn = nodeCLI.exec(
"nyc",
MOCHA,
"--color",
"--reporter progress",
"--timeout 30000",
TEST_FILES
);

if (lastReturn.code !== 0) {
errors++;
Expand Down Expand Up @@ -114,9 +124,14 @@ target.browserify = function() {
cp("espree.js", TEMP_DIR);
cp("package.json", TEMP_DIR);


// 3. browserify the temp directory
nodeCLI.exec("browserify", path.join(TEMP_DIR, "espree.js"), "-o", path.join(BUILD_DIR, "espree.js"), "-s espree");
nodeCLI.exec(
"browserify",
path.join(TEMP_DIR, "espree.js"),
"-o",
path.join(BUILD_DIR, "espree.js"),
"-s espree"
);

// 4. remove temp directory
rm("-r", TEMP_DIR);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"generate-regex": "node tools/generate-identifier-regex.js",
"test": "npm run-script lint && node Makefile.js test",
"lint": "node Makefile.js lint",
"fixlint": "node Makefile.js lint --fix",
"browserify": "node Makefile.js browserify",
"generate-release": "eslint-generate-release",
"generate-alpharelease": "eslint-generate-prerelease alpha",
Expand Down