Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Dec 23, 2019
1 parent 4b7cd7a commit e8c5792
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yml
Expand Up @@ -9,3 +9,5 @@ rules:
- error
- name: child_process
message: Please use cross-spawn instead.

no-console: off
23 changes: 12 additions & 11 deletions canary.js
Expand Up @@ -41,23 +41,23 @@ function createTempFolder() {
}

/**
* Synchronously spawn a child process, and throw if it exits with an error
* @param {string} command The command to spawn
* @param {string[]} args Arguments for the command
* @returns {void}
*/
* Synchronously spawn a child process, and throw if it exits with an error
* @param {string} command The command to spawn
* @param {string[]} args Arguments for the command
* @returns {void}
*/
function spawn(command, args) {
const result = spawnSync(command, args);

assert.strictEqual(result.status, 0, `The command '${command} ${args.join(" ")}' exited with an exit code of ${result.status}:\n\n${result.output[2].toString()}`);
}

/**
* Determines whether a particular dependency of a project should be installed
* @param {object} projectInfo The project information in the yml file
* @param {string} dependency The name of the dependency
* @returns {boolean} `true` if the dependency should be installed
*/
* Determines whether a particular dependency of a project should be installed
* @param {Object} projectInfo The project information in the yml file
* @param {string} dependency The name of the dependency
* @returns {boolean} `true` if the dependency should be installed
*/
function shouldInstall(projectInfo, dependency) {
return dependency.includes("eslint") && dependency !== "eslint" ||
projectInfo.dependencies && projectInfo.dependencies.indexOf(dependency) !== -1;
Expand Down Expand Up @@ -92,7 +92,7 @@ projects.forEach(projectInfo => {

npmInstallArgs = Array.from(new Set(Object.keys(dependencyVersions).concat(projectInfo.dependencies || [])))
.filter(dependency => shouldInstall(projectInfo, dependency))
.map(dependency => dependencyVersions[dependency] ? `${dependency}@${dependencyVersions[dependency]}` : dependency);
.map(dependency => (dependencyVersions[dependency] ? `${dependency}@${dependencyVersions[dependency]}` : dependency));
}

console.log(`Installing dependencies for ${projectInfo.name}`);
Expand All @@ -110,6 +110,7 @@ projects.forEach(projectInfo => {
console.log(`Linting ${projectInfo.name}`);

const result = spawnSync(eslintBinPath, projectInfo.args.concat("--format=codeframe"));

if (result.status === 0) {
console.log(`Successfully linted ${projectInfo.name} with no errors`);
} else {
Expand Down
6 changes: 3 additions & 3 deletions validate-projects.js
Expand Up @@ -9,7 +9,7 @@ assert.isArray(projects, "projects.yml must parse as an array");

projects.forEach(projectInfo => {
assert.typeOf(projectInfo.name, "string", "Project names must be strings");
assert.match(projectInfo.name, /^[\w-]+$/, `Project name must only contain alphanumeric characters and dashes. ('${projectInfo.name}' contains special characters.)`);
assert.match(projectInfo.name, /^[\w-]+$/u, `Project name must only contain alphanumeric characters and dashes. ('${projectInfo.name}' contains special characters.)`);
assert.typeOf(projectInfo.repo, "string");
assert.isArray(projectInfo.args, `Expected the arguments for ${projectInfo.name} to be an array`);

Expand All @@ -20,7 +20,7 @@ projects.forEach(projectInfo => {
assert.isArray(projectInfo.dependencies, "Project dependencies must be in an array");
}

assert.match(projectInfo.commit, /^[0-9a-f]{40}$/, "Project commit must be a full commit hash");
assert.match(projectInfo.commit, /^[0-9a-f]{40}$/u, "Project commit must be a full commit hash");
});

assert.deepEqual(projects.map(project => project.name), projects.map(project => project.name).sort(), "Project names should be sorted");
assert.deepStrictEqual(projects.map(project => project.name), projects.map(project => project.name).sort(), "Project names should be sorted");

0 comments on commit e8c5792

Please sign in to comment.