ESLintify Part 3 (#846)

* ESLintify Part 3

* ESLintify Part 3

* ESLintify Part 3
This commit is contained in:
Yangshun Tay 2018-07-11 03:21:31 -07:00 committed by Endilie Yacop Sucipto
parent 5ac2cee658
commit a7a214fb3a
54 changed files with 435 additions and 497 deletions

View file

@ -29,16 +29,16 @@ const nodePath = require('path');
const readMetadata = require('./server/readMetadata.js');
const CWD = process.cwd();
const siteConfig = require(CWD + '/siteConfig.js');
const sidebars = require(CWD + '/sidebars.json');
const siteConfig = require(`${CWD}/siteConfig.js`);
const sidebars = require(`${CWD}/sidebars.json`);
let customTranslations = {
'localized-strings': {},
'pages-strings': {},
};
if (fs.existsSync(CWD + '/data/custom-translation-strings.json')) {
if (fs.existsSync(`${CWD}/data/custom-translation-strings.json`)) {
customTranslations = JSON.parse(
fs.readFileSync(CWD + '/data/custom-translation-strings.json', 'utf8')
fs.readFileSync(`${CWD}/data/custom-translation-strings.json`, 'utf8')
);
}
@ -59,7 +59,7 @@ function execute() {
// look through markdown headers of docs for titles and categories to translate
const docsDir = nodePath.join(CWD, '../', readMetadata.getDocsPath());
let files = glob.sync(CWD + '/../' + readMetadata.getDocsPath() + '/**');
let files = glob.sync(`${CWD}/../${readMetadata.getDocsPath()}/**`);
files.forEach(file => {
const extension = nodePath.extname(file);
if (extension === '.md' || extension === '.markdown') {
@ -98,7 +98,7 @@ function execute() {
});
});
files = glob.sync(CWD + '/versioned_sidebars/*');
files = glob.sync(`${CWD}/versioned_sidebars/*`);
files.forEach(file => {
if (!file.endsWith('-sidebars.json')) {
if (file.endsWith('-sidebar.json')) {
@ -125,7 +125,7 @@ function execute() {
});
// go through pages to look for text inside translate tags
files = glob.sync(CWD + '/pages/en/**');
files = glob.sync(`${CWD}/pages/en/**`);
files.forEach(file => {
const extension = nodePath.extname(file);
if (extension === '.js') {
@ -148,7 +148,7 @@ function execute() {
description = attributes[i].value.value;
}
}
translations['pages-strings'][text + '|' + description] = text;
translations['pages-strings'][`${text}|${description}`] = text;
}
},
});
@ -177,8 +177,8 @@ function execute() {
customTranslations['localized-strings']
);
writeFileAndCreateFolder(
CWD + '/i18n/en.json',
JSON.stringify(
`${CWD}/i18n/en.json`,
`${JSON.stringify(
Object.assign(
{
_comment: 'This file is auto-generated by write-translations.js',
@ -187,7 +187,7 @@ function execute() {
),
null,
2
) + '\n'
)}\n`
);
}