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

Fix remaining lint errors in build-system and enforce lint checks via Travis #11365

Merged
merged 6 commits into from Sep 21, 2017
Merged

Fix remaining lint errors in build-system and enforce lint checks via Travis #11365

merged 6 commits into from Sep 21, 2017

Conversation

rsimha
Copy link
Contributor

@rsimha rsimha commented Sep 20, 2017

Follow up to #11325
Follow up to #11334
Follow up to #11357
Fixes #11273

@rsimha rsimha changed the title Manually fix remaining lint errors build-system and enforce lint checks Manually fix remaining lint errors in build-system and enforce lint checks in future Sep 20, 2017
@rsimha
Copy link
Contributor Author

rsimha commented Sep 20, 2017

/to @choumx @erwinmombay @jridgewell

@rsimha rsimha changed the title Manually fix remaining lint errors in build-system and enforce lint checks in future Fix all lint errors in build-system and enforce lint checks in pr-check.js Sep 20, 2017
@rsimha rsimha changed the title Fix all lint errors in build-system and enforce lint checks in pr-check.js Fix remaining lint errors in build-system and enforce lint checks via Travis Sep 20, 2017
@rsimha
Copy link
Contributor Author

rsimha commented Sep 20, 2017

/to @cramforce

@@ -14,6 +14,8 @@
* limitations under the License.
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't be linting this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -27,4 +27,4 @@
* @return {function(number):T}
* @template T
*/
var TransitionDef = function(unusedNormtime, unusedCompleted) {};
const TransitionDef = function(unusedNormtime, unusedCompleted) {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be linting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -24,4 +24,4 @@
* transition and "false" for ongoing.
* @typedef {function(number, boolean):?|function(number):?}
*/
var TransitionDef;
let TransitionDef;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be linting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -1199,4 +1198,4 @@ function generateInfo(filePath) {
'<h3><a href = /serve_mode=cdn>Change to CDN mode (prod JS)</a></h3>';
}

module.exports = app;
module.exports = app; // eslint-disable-line no-undef
Copy link
Contributor

Choose a reason for hiding this comment

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

What's undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Linter complains that module is undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed after setting env to node.

'!build-system/eslint-rules/**/*.*',
'!build-system/node_modules/**/*.*',
],
module.exports = { // eslint-disable-line no-undef
Copy link
Contributor

Choose a reason for hiding this comment

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

What's undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed after setting env to node.

@@ -38,12 +38,10 @@ let Tables;
* size: string
* }}
*/
let Fields;
let Fields; // eslint-disable-line no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

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

FieldsDef

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -223,7 +219,7 @@ function flattenGraph(entryPoints) {
entryPoints = entryPoints.map(entryPoint => entryPoint.deps);
// Now make the graph have unique entries
return flatten(entryPoints)
.reduce((acc, cur, i, arr) => {
.reduce((acc, cur, unusedI, unusedArr) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -92,7 +91,7 @@ function generate(root, target, writeToDisk) {
const dirname = path.relative(process.cwd(), path.dirname(file.path));
dirs[dirname || '*'] = yaml.parse(file.contents.toString());
}))
.on('end', function(cb) {
.on('end', function(unusedCb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -76,7 +76,7 @@ function onFileThrough(file, enc, cb) {
postcss([zIndexCollector.bind(null, selectors)])
.process(file.contents.toString(), {
from: file.relative,
}).then(res => {
}).then(unusedRes => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -18,7 +18,7 @@
/**
* @param {!Object} config
*/
module.exports = {
module.exports = { // eslint-disable-line no-undef
Copy link
Contributor

Choose a reason for hiding this comment

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

We should set the eslintrc to node environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

@jridgewell all comments addressed. PTAL.

@@ -536,7 +536,7 @@ function buildPrMetadata(pr) {
id: pr.number,
title: pr.title,
body: pr.body,
merge_commit_sha: pr.merge_commit_sha,
merge_commit_sha: pr.merge_commit_sha, // eslint-disable-line google-camelcase/google-camelcase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried quotes. The error is in pr.merge_commit_sha, which appears to be a well defined github constant.

@@ -14,6 +14,8 @@
* limitations under the License.
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -27,4 +27,4 @@
* @return {function(number):T}
* @template T
*/
var TransitionDef = function(unusedNormtime, unusedCompleted) {};
const TransitionDef = function(unusedNormtime, unusedCompleted) {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -24,4 +24,4 @@
* transition and "false" for ongoing.
* @typedef {function(number, boolean):?|function(number):?}
*/
var TransitionDef;
let TransitionDef;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

'!build-system/eslint-rules/**/*.*',
'!build-system/node_modules/**/*.*',
],
module.exports = { // eslint-disable-line no-undef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

module.

@@ -92,7 +91,7 @@ function generate(root, target, writeToDisk) {
const dirname = path.relative(process.cwd(), path.dirname(file.path));
dirs[dirname || '*'] = yaml.parse(file.contents.toString());
}))
.on('end', function(cb) {
.on('end', function(unusedCb) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -76,7 +76,7 @@ function onFileThrough(file, enc, cb) {
postcss([zIndexCollector.bind(null, selectors)])
.process(file.contents.toString(), {
from: file.relative,
}).then(res => {
}).then(unusedRes => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -18,7 +18,7 @@
/**
* @param {!Object} config
*/
module.exports = {
module.exports = { // eslint-disable-line no-undef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1199,4 +1198,4 @@ function generateInfo(filePath) {
'<h3><a href = /serve_mode=cdn>Change to CDN mode (prod JS)</a></h3>';
}

module.exports = app;
module.exports = app; // eslint-disable-line no-undef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed after setting env to node.

'!build-system/eslint-rules/**/*.*',
'!build-system/node_modules/**/*.*',
],
module.exports = { // eslint-disable-line no-undef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed after setting env to node.

@@ -536,7 +536,7 @@ function buildPrMetadata(pr) {
id: pr.number,
title: pr.title,
body: pr.body,
merge_commit_sha: pr.merge_commit_sha,
merge_commit_sha: pr.merge_commit_sha, // eslint-disable-line google-camelcase/google-camelcase
Copy link
Contributor

Choose a reason for hiding this comment

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

Both can use quotes.

@@ -87,11 +87,11 @@ function onFileThrough(file, enc, cb) {
* @param {function()} cb callback to end the stream
* @return {!Array<!Array<string>>}
*/
function createTable(filesData, cb) {
function createTable(filesData, unusedCb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove anything that starts with "unused".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scanned the whole PR, removed all others.

@@ -26,7 +26,7 @@ const through2 = require('through2');
function checkValidJson() {
let hasError = false;
return gulp.src(jsonGlobs)
.pipe(through2.obj(function(file, enc, cb) {
.pipe(through2.obj(function(file, unusedEnc, unusedCb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -204,7 +204,7 @@ function diffScreenshot_(file, dir, host, verbose, cb) {
util.log(util.colors.red('Screenshot diff failed: ', file, error));
cb({error});
})
.on('end', function(res) {
.on('end', function(unusedRes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -155,7 +150,7 @@ function gitFetch(dir) {
args: 'clone https://github.com/ampproject/amphtml.git',
});
}
return clonePromise.then(function(arg) {
return clonePromise.then(function(unusedArg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Contributor Author

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

All fixes applied. PTAL @jridgewell

@@ -164,12 +161,13 @@ function mergeTables(dateTimes, tables) {
// populate all other columns with their respective file size if any.
dateTimes.forEach(dateTime => {
// Seed array with empty string values
const row = Array.apply(null, Array(tableHeaders[0].length)).map(x => '""');
const row =
Array.apply(null, Array(tableHeaders[0].length)).map(unusedX => '""');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -26,7 +26,7 @@ const through2 = require('through2');
function checkValidJson() {
let hasError = false;
return gulp.src(jsonGlobs)
.pipe(through2.obj(function(file, enc, cb) {
.pipe(through2.obj(function(file, unusedEnc, unusedCb) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -87,11 +87,11 @@ function onFileThrough(file, enc, cb) {
* @param {function()} cb callback to end the stream
* @return {!Array<!Array<string>>}
*/
function createTable(filesData, cb) {
function createTable(filesData, unusedCb) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scanned the whole PR, removed all others.

@@ -204,7 +204,7 @@ function diffScreenshot_(file, dir, host, verbose, cb) {
util.log(util.colors.red('Screenshot diff failed: ', file, error));
cb({error});
})
.on('end', function(res) {
.on('end', function(unusedRes) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -155,7 +150,7 @@ function gitFetch(dir) {
args: 'clone https://github.com/ampproject/amphtml.git',
});
}
return clonePromise.then(function(arg) {
return clonePromise.then(function(unusedArg) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -536,7 +536,7 @@ function buildPrMetadata(pr) {
id: pr.number,
title: pr.title,
body: pr.body,
merge_commit_sha: pr.merge_commit_sha,
merge_commit_sha: pr.merge_commit_sha, // eslint-disable-line google-camelcase/google-camelcase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just the field names needed quotes. The rest is fixed with env being set to node.

@rsimha
Copy link
Contributor Author

rsimha commented Sep 21, 2017

@choumx @jridgewell Can I bug one of you to take another look at this? I'd like to merge this soon since any conflicting changes that get merged before this will be a pain to resolve.

@@ -313,7 +312,7 @@ function proxyToAmpProxy(req, res, mode) {
body = body
// Unversion URLs.
.replace(/https\:\/\/cdn\.ampproject\.org\/rtv\/\d+\//g,
'https://cdn.ampproject.org/')
'https://cdn.ampproject.org/')

Choose a reason for hiding this comment

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

Is this indentation right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per our existing rules, it is right. First continuation line is indented by 4 spaces, following lines use the same indentation. This was done automatically by --fix, and wasn't a manual change. If this seems wrong to you, I could look at adding a more refined rule and rerunning the linter in --fix mode across all our files.

@rsimha rsimha dismissed jridgewell’s stale review September 21, 2017 16:53

Thanks for the review. All your comments have been addressed.

@rsimha rsimha merged commit ee2dea7 into ampproject:master Sep 21, 2017
@rsimha rsimha deleted the 2017-09-20-FixRemainingLintErrors branch September 21, 2017 16:55
dmvjs pushed a commit to dmvjs/amphtml that referenced this pull request Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants