Skip to content

Commit 46c36ad

Browse files
authored
Merge pull request apache#994 from raphinesse/fix-eslint
Improve ESLint setup and fix linting errors
2 parents 338fb7a + 0132111 commit 46c36ad

File tree

8 files changed

+242
-244
lines changed

8 files changed

+242
-244
lines changed

gulpfile.js

Lines changed: 222 additions & 222 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "gulp clean",
1313
"update-docs": "gulp snapshot",
1414
"build": "gulp build --prod",
15-
"eslint": "eslint tools/lib tools/spec"
15+
"eslint": "eslint tools *.js"
1616
},
1717
"author": "Apache Software Foundation",
1818
"license": "Apache-2.0",
@@ -46,13 +46,13 @@
4646
"babel-plugin-transform-h-jsx": "^1.0.0",
4747
"babel-preset-react": "^6.24.1",
4848
"babelify": "^7.3.0",
49-
"eslint": "^4.10.0",
50-
"eslint-config-semistandard": "^11.0.0",
51-
"eslint-config-standard": "^10.2.1",
49+
"eslint": "^5.16.0",
50+
"eslint-config-semistandard": "^13.0.0",
51+
"eslint-config-standard": "^12.0.0",
5252
"eslint-plugin-import": "^2.8.0",
53-
"eslint-plugin-node": "^5.2.1",
54-
"eslint-plugin-promise": "^3.6.0",
55-
"eslint-plugin-standard": "^3.0.1",
53+
"eslint-plugin-node": "^9.0.1",
54+
"eslint-plugin-promise": "^4.1.1",
55+
"eslint-plugin-standard": "^4.0.0",
5656
"glob": "^7.0.3",
5757
"gulp-htmllint": "^0.0.5",
5858
"simplecrawler": "^0.5.2"

tools/bin/augment_toc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ var chalk = require('chalk');
2727
var util = require('./util');
2828

2929
// constants
30-
var DEFAULT_PREFIX = '';
3130
var VERBOSE_BY_DEFAULT = false;
3231

3332
// globals
@@ -121,7 +120,7 @@ function augmentToc (originalToc, prefix) {
121120
function augmentString (srcTocString, prefix) {
122121
var srcToc = yaml.load(srcTocString);
123122
var augmentedToc = augmentToc(srcToc, prefix);
124-
var augmentedTocString = yaml.dump(augmentedToc, {indent: 4});
123+
var augmentedTocString = yaml.dump(augmentedToc, { indent: 4 });
125124

126125
return augmentedTocString;
127126
}

tools/bin/fetch_docs.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ function getLatestRelease (packageName) {
5454
}
5555

5656
function packageNameFromRepoName (repoName) {
57-
var repoSplit = repoName.split('/');
58-
var repoOwner = repoSplit[0];
59-
var actualRepoName = repoSplit[1];
60-
return actualRepoName;
57+
return repoName.split('/')[1];
6158
}
6259

6360
function getFetchedFileConfig (entry) {
@@ -192,7 +189,7 @@ function downloadEntries (downloadPrefix, entries) {
192189
var outFile = fs.createWriteStream(outFilePath);
193190

194191
// open an HTTP request for the file
195-
var request = https.get(fetchURI, function (response) {
192+
https.get(fetchURI, function (response) {
196193

197194
if (response.statusCode !== 200) {
198195
console.error('Failed to download ' + fetchURI + ': got ' + response.statusCode);

tools/bin/gen_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function main () {
5656
}
5757

5858
// create defaults config
59-
var config = {'defaults': []};
59+
var config = { 'defaults': [] };
6060

6161
// set defaults for each language
6262
util.listdirsSync(rootDir).forEach(function (langName) {
@@ -114,7 +114,7 @@ function main () {
114114
});
115115

116116
console.log(util.generatedBy(__filename));
117-
console.log(yaml.dump(config, {indent: 4}));
117+
console.log(yaml.dump(config, { indent: 4 }));
118118
}
119119

120120
main();

tools/bin/gen_pages_dict.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ function main () {
9292
// add entries for all Markdown files in the site root
9393
var allMarkdownFiles = path.join(siteRootPath, '**/*.md');
9494
glob(allMarkdownFiles, function (error, filePaths) {
95+
if (error) throw error;
96+
9597
for (var i = 0; i < filePaths.length; i++) {
9698
var filePath = filePaths[i];
9799
var fileURI = pathToURI(filePath, siteRootPath);

tools/bin/gen_versions.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,21 @@ function main () {
5656
var versionNames = util.listdirsSync(langPath);
5757

5858
// get language ID
59-
var langName;
60-
if (langId in LANGUAGE_MAP) {
61-
langName = LANGUAGE_MAP[langId];
62-
} else {
59+
var langName = LANGUAGE_MAP[langId];
60+
if (!langName) {
6361
console.error("Language identifier '" + langId + "' doesn't have an associated name. Please fix that by changing " + scriptName + '.');
6462
process.exit(1);
6563
}
6664

6765
// set the language name and the versions it has
6866
config[langId] = {
69-
'name': LANGUAGE_MAP[langId],
67+
'name': langName,
7068
'versions': versionNames
7169
};
7270
});
7371

7472
console.log(util.generatedBy(__filename));
75-
console.log(yaml.dump(config, {indent: 4}));
73+
console.log(yaml.dump(config, { indent: 4 }));
7674
}
7775

7876
main();

tools/bin/toc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function main () {
5454

5555
// read the input
5656
fs.readFile(srcTocPath, function (error, data) {
57+
if (error) throw error;
5758

5859
// augment the ToC
5960
var originalTocString = data.toString();
@@ -63,6 +64,7 @@ function main () {
6364

6465
// write the output
6566
fs.writeFile(destTocPath, output, function (error, data) {
67+
if (error) throw error;
6668
console.log(srcTocPath + ' -> ' + destTocPath);
6769
});
6870
});

0 commit comments

Comments
 (0)