Skip to content

Commit

Permalink
Update eslint to v6 (#1777)
Browse files Browse the repository at this point in the history
* Update eslint

* Do eslint --fix

* Do not access Object.prototype method 'hasOwnProperty' from target object

* utils: add hasProperty

* eslint --fix

* Disable quote-props for locale files

* add back quotes in locale files

* revert locale files to state on master

* Update react-scripts
  • Loading branch information
goto-bus-stop authored and arturi committed Aug 13, 2019
1 parent 2ed93fc commit c62ec36
Show file tree
Hide file tree
Showing 58 changed files with 1,956 additions and 1,782 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Expand Up @@ -53,7 +53,8 @@
"packages/@uppy/locales/template.js"
],
"rules": {
"camelcase": "off"
"camelcase": "off",
"quote-props": "off"
}
}]
}
2 changes: 1 addition & 1 deletion babel.config.js
@@ -1,5 +1,5 @@
module.exports = (api) => {
let targets = {}
const targets = {}
if (api.env('test')) {
targets.node = 'current'
}
Expand Down
2 changes: 1 addition & 1 deletion bin/build-css.js
Expand Up @@ -44,7 +44,7 @@ async function compileCSS () {
}
})

const postcssResult = await postcss([ autoprefixer ])
const postcssResult = await postcss([autoprefixer])
.process(scssResult.css, { from: file })
postcssResult.warnings().forEach(function (warn) {
console.warn(warn.toString())
Expand Down
24 changes: 12 additions & 12 deletions bin/locale-packs.js
Expand Up @@ -24,7 +24,7 @@ if (mode === 'build') {
function getSources (pluginName) {
const dependencies = {
// because 'provider-views' doesn't have its own locale, it uses Core's defaultLocale
'core': ['provider-views']
core: ['provider-views']
}

const globPath = path.join(__dirname, '..', 'packages', '@uppy', pluginName, 'lib', '**', '*.js')
Expand All @@ -50,7 +50,7 @@ function buildPluginsList () {
const files = glob.sync(packagesGlobPath)

console.log(`--> Checked plugins could be instantiated and have defaultLocale in them:\n`)
for (let file of files) {
for (const file of files) {
const dirName = path.dirname(file)
const pluginName = path.basename(dirName)
if (pluginName === 'locales' || pluginName === 'react-native') {
Expand Down Expand Up @@ -123,7 +123,7 @@ function buildPluginsList () {
function addLocaleToPack (plugin, pluginName) {
const localeStrings = plugin.defaultLocale.strings

for (let key in localeStrings) {
for (const key in localeStrings) {
const valueInPlugin = JSON.stringify(localeStrings[key])
const valueInPack = JSON.stringify(localePack[key])

Expand All @@ -138,9 +138,9 @@ function addLocaleToPack (plugin, pluginName) {
}

function checkForUnused (fileContents, pluginName, localePack) {
let buff = fileContents.join('\n')
for (let key in localePack) {
let regPat = new RegExp(`(i18n|i18nArray)\\([^\\)]*['\`"]${key}['\`"]`, 'g')
const buff = fileContents.join('\n')
for (const key in localePack) {
const regPat = new RegExp(`(i18n|i18nArray)\\([^\\)]*['\`"]${key}['\`"]`, 'g')
if (!buff.match(regPat)) {
console.error(`⚠ defaultLocale key: ${chalk.magenta(key)} not used in plugin: ${chalk.cyan(pluginName)}`)
}
Expand All @@ -157,13 +157,13 @@ function sortObjectAlphabetically (obj, sortFunc) {
function build () {
const { plugins, sources } = buildPluginsList()

for (let pluginName in plugins) {
for (const pluginName in plugins) {
addLocaleToPack(plugins[pluginName], pluginName)
}

localePack = sortObjectAlphabetically(localePack)

for (let pluginName in sources) {
for (const pluginName in sources) {
checkForUnused(sources[pluginName], pluginName, sortObjectAlphabetically(plugins[pluginName].defaultLocale.strings))
}

Expand Down Expand Up @@ -204,10 +204,10 @@ function test () {
// Compare all follower Locales (RU, DE, etc) with our leader en_US
const warnings = []
const fatals = []
for (let followerName in followerLocales) {
let followerLocale = followerLocales[followerName]
let missing = leadingLocale.filter((key) => !followerLocale.includes(key))
let excess = followerLocale.filter((key) => !leadingLocale.includes(key))
for (const followerName in followerLocales) {
const followerLocale = followerLocales[followerName]
const missing = leadingLocale.filter((key) => !followerLocale.includes(key))
const excess = followerLocale.filter((key) => !leadingLocale.includes(key))

missing.forEach((key) => {
// Items missing are a non-fatal warning because we don't want CI to bum out over all languages
Expand Down

0 comments on commit c62ec36

Please sign in to comment.