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
Fix remaining lint errors in build-system
and enforce lint checks via Travis
#11365
Conversation
build-system
and enforce lint checksbuild-system
and enforce lint checks in future
build-system
and enforce lint checks in futurebuild-system
and enforce lint checks in pr-check.js
build-system
and enforce lint checks in pr-check.jsbuild-system
and enforce lint checks via Travis
/to @cramforce |
build-system/amp.extern.js
Outdated
@@ -14,6 +14,8 @@ | |||
* limitations under the License. | |||
*/ | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/amp.nti.extern.js
Outdated
@@ -27,4 +27,4 @@ | |||
* @return {function(number):T} | |||
* @template T | |||
*/ | |||
var TransitionDef = function(unusedNormtime, unusedCompleted) {}; | |||
const TransitionDef = function(unusedNormtime, unusedCompleted) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be linting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/amp.oti.extern.js
Outdated
@@ -24,4 +24,4 @@ | |||
* transition and "false" for ongoing. | |||
* @typedef {function(number, boolean):?|function(number):?} | |||
*/ | |||
var TransitionDef; | |||
let TransitionDef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be linting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/app.js
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's undefined?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/config.js
Outdated
'!build-system/eslint-rules/**/*.*', | ||
'!build-system/node_modules/**/*.*', | ||
], | ||
module.exports = { // eslint-disable-line no-undef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FieldsDef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
build-system/tasks/dep-check.js
Outdated
@@ -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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
build-system/tasks/karma.conf.js
Outdated
@@ -18,7 +18,7 @@ | |||
/** | |||
* @param {!Object} config | |||
*/ | |||
module.exports = { | |||
module.exports = { // eslint-disable-line no-undef |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this 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.
build-system/tasks/changelog.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
build-system/amp.extern.js
Outdated
@@ -14,6 +14,8 @@ | |||
* limitations under the License. | |||
*/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/amp.nti.extern.js
Outdated
@@ -27,4 +27,4 @@ | |||
* @return {function(number):T} | |||
* @template T | |||
*/ | |||
var TransitionDef = function(unusedNormtime, unusedCompleted) {}; | |||
const TransitionDef = function(unusedNormtime, unusedCompleted) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/amp.oti.extern.js
Outdated
@@ -24,4 +24,4 @@ | |||
* transition and "false" for ongoing. | |||
* @typedef {function(number, boolean):?|function(number):?} | |||
*/ | |||
var TransitionDef; | |||
let TransitionDef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
build-system/config.js
Outdated
'!build-system/eslint-rules/**/*.*', | ||
'!build-system/node_modules/**/*.*', | ||
], | ||
module.exports = { // eslint-disable-line no-undef |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
build-system/tasks/karma.conf.js
Outdated
@@ -18,7 +18,7 @@ | |||
/** | |||
* @param {!Object} config | |||
*/ | |||
module.exports = { | |||
module.exports = { // eslint-disable-line no-undef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
build-system/app.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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/config.js
Outdated
'!build-system/eslint-rules/**/*.*', | ||
'!build-system/node_modules/**/*.*', | ||
], | ||
module.exports = { // eslint-disable-line no-undef |
There was a problem hiding this comment.
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/tasks/changelog.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
build-system/tasks/json-check.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
build-system/tasks/make-golden.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this 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 => '""'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
build-system/tasks/json-check.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
build-system/tasks/make-golden.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
build-system/tasks/changelog.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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
.
@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/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this indentation right?
There was a problem hiding this comment.
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.
Thanks for the review. All your comments have been addressed.
Follow up to #11325
Follow up to #11334
Follow up to #11357
Fixes #11273