Skip to content

Commit

Permalink
fix(scripts): Fix lint issues (#99)
Browse files Browse the repository at this point in the history
- Fix all lint issues in the scripts/ dir
- Ensure `lint:js` npm script lints the scripts/ dir
  • Loading branch information
traviskaufman committed Dec 15, 2016
1 parent dc25b4d commit 1f18e92
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -12,7 +12,7 @@
"fix:js": "eslint --fix packages test webpack.config.js karma.conf.js",
"fix:css": "stylefmt -R packages",
"fix": "npm-run-all --parallel fix:*",
"lint:js": "eslint packages test webpack.config.js karma.conf.js",
"lint:js": "eslint packages test scripts webpack.config.js karma.conf.js",
"lint:css": "stylelint packages/**/*.scss",
"lint": "npm-run-all --parallel lint:*",
"postinstall": "lerna bootstrap",
Expand Down
2 changes: 1 addition & 1 deletion scripts/cp-pkgs.js
Expand Up @@ -60,7 +60,7 @@ function cpAsset(asset) {
return cpFile(asset, destDir).then(() => console.log(`cp ${asset} -> ${destDir}`));
}

Promise.all(globSync('build/*.{css,js}').map(cpAsset)).catch(err => {
Promise.all(globSync('build/*.{css,js}').map(cpAsset)).catch((err) => {
console.error(`Error encountered copying assets: ${err}`);
process.exit(1);
});
26 changes: 13 additions & 13 deletions scripts/determine-pkg-versions.js
Expand Up @@ -61,7 +61,7 @@ const PKGS_PATH = path.resolve(__dirname, '../packages');
const VersionType = {
MAJOR: 'major',
MINOR: 'minor',
PATCH: 'patch'
PATCH: 'patch',
};

const updatedPkgs = getUpdatedPkgs();
Expand All @@ -74,25 +74,25 @@ const commitMatches = childProcess
.execSync(GIT_LOG_CMD)
.toString()
.split(MAGICAL_DELIMITER)
.map(c => {
.map((c) => {
const trimmedCommit = c.trim();
const m = trimmedCommit.match(COMMIT_MSG_RE);
return m && {
commit: trimmedCommit,
type: m[1],
scope: m[2],
hasBreakingChange: trimmedCommit.split('\n').some(l => BREAKING_CHANGE_RE.test(l))
hasBreakingChange: trimmedCommit.split('\n').some((l) => BREAKING_CHANGE_RE.test(l)),
};
})
.filter(info => Boolean(info) && affectsPackage(info.scope));
.filter((info) => Boolean(info) && affectsPackage(info.scope));
const componentPkgs = updatedPkgs.filter(({name}) => name !== 'material-components-web');
const mdcPkg = updatedPkgs.find(({name}) => name === 'material-components-web');
const newPkgVersions = collectNewPkgVersions(componentPkgs, commitMatches);
const newMDCVersion = {
name: 'material-components-web',
version: collectMDCVersion(mdcPkg, newPkgVersions),
changeType: 'N/A',
causedByCommit: 'N/A'
causedByCommit: 'N/A',
};

const allPkgVersions = [newMDCVersion].concat(newPkgVersions);
Expand All @@ -104,13 +104,13 @@ function affectsPackage(commitScope) {
}

function collectNewPkgVersions(updatedPkgs, commitInfos) {
return updatedPkgs.map(p => {
return updatedPkgs.map((p) => {
const {version, changeType, causedByCommit} = determineVersion(p, commitInfos);
return {
name: p.name,
version,
changeType,
causedByCommit
causedByCommit,
};
});
}
Expand All @@ -126,7 +126,7 @@ function determineVersion(pkg, commitInfos) {
return commitInfos.reduce(pickBestVersionInfo(pkg), {
version: currentVersion,
changeType: '',
causedByCommit: ''
causedByCommit: '',
});
}

Expand Down Expand Up @@ -156,7 +156,7 @@ function pickBestVersionInfo(pkg) {
return {
version: possibleNewVersion,
changeType: possibleNewChangeType,
causedByCommit: commitInfo.commit
causedByCommit: commitInfo.commit,
};
};
}
Expand All @@ -172,7 +172,7 @@ function collectMDCVersion(mdcPkg, newPkgVersions) {
const versionRanks = {
[VersionType.PATCH]: 0,
[VersionType.MINOR]: 1,
[VersionType.MAJOR]: 2
[VersionType.MAJOR]: 2,
};
const overallChangeType = [...changeTypes]
.sort((ct1, ct2) => versionRanks[ct1] - versionRanks[ct2])
Expand All @@ -184,7 +184,7 @@ function writeSummary(pkgVersions, performWrite) {
const title = 'New Package Versions';
const headers = ['Package', 'Version', 'Change Type', 'Associated Commit Subject'];
const rows = pkgVersions.map(({name, version, changeType, causedByCommit}) => [
name, version, changeType, causedByCommit.split('\n').shift()
name, version, changeType, causedByCommit.split('\n').shift(),
]);

performWrite(title, headers, rows);
Expand All @@ -193,7 +193,7 @@ function writeSummary(pkgVersions, performWrite) {
function writeSummaryToScreen(pkgVersions) {
writeSummary(pkgVersions, (title, headers, rows) => {
const table = new CliTable({
head: headers
head: headers,
});
table.push(...rows);
console.log(`*** ${title} ***`);
Expand All @@ -206,7 +206,7 @@ function writeSummaryToFile(pkgVersions) {
const table = AsciiTable.factory({
title,
heading: headers,
rows
rows,
});
const outFile = path.join(process.cwd(), '.new-versions.log');
fs.writeFileSync(outFile, table.toString());
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/get-updated-pkgs.js
Expand Up @@ -43,13 +43,13 @@ module.exports = function() {
get: () => null,
set: () => {},
enumerable: true,
configurable: true
configurable: true,
});

const updates = collector.getUpdates();

Object.defineProperty(progressBar, 'bar', origBarDescriptor);
lernaLogger.info = origInfoFn;

return updates.map(u => u.package);
return updates.map((u) => u.package);
};

0 comments on commit 1f18e92

Please sign in to comment.