Skip to content

Commit

Permalink
meta: update linter config to parse ESM files (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 15, 2021
1 parent b0bf1a3 commit 66692cc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.js
Expand Up @@ -145,6 +145,17 @@ module.exports = {
},

overrides: [
{
files: [
'*.mjs',
'private/dev/*.js',
'private/release/*.js',
'private/remark-lint-uppy/*.js',
],
parserOptions: {
sourceType: 'module',
},
},
{
files: ['./packages/@uppy/companion/**/*.js'],
rules: {
Expand Down
4 changes: 3 additions & 1 deletion packages/uppy/index.mjs
Expand Up @@ -3,8 +3,10 @@ export { default as Core } from '@uppy/core'

// Utilities
export { default as server } from '@uppy/companion-client'
/* eslint-disable */
import ProviderView from '@uppy/provider-views'
export var views = { ProviderView: ProviderView }
export var views = { ProviderView }
/* eslint-enable */

// Stores
export { default as DefaultStore } from '@uppy/store-default'
Expand Down
2 changes: 1 addition & 1 deletion private/locale-pack/helpers.mjs
Expand Up @@ -11,7 +11,7 @@ export function getPaths (globPath) {

export function sortObjectAlphabetically (obj) {
return Object.fromEntries(
Object.entries(obj).sort(([keyA], [keyB]) => keyA.localeCompare(keyB))
Object.entries(obj).sort(([keyA], [keyB]) => keyA.localeCompare(keyB)),
)
}

Expand Down
4 changes: 2 additions & 2 deletions private/locale-pack/index.mjs
Expand Up @@ -106,7 +106,7 @@ function generateTypes (pluginName, locale) {
'@uppy',
pluginName,
'types',
'generatedLocale.d.ts'
'generatedLocale.d.ts',
)

const localeTypes = dedent`
Expand All @@ -131,7 +131,7 @@ function generateLocaleDocs (pluginName) {

if (!fs.existsSync(docPath)) {
console.error(
`⚠️ Could not find markdown documentation file for "${pluginName}". Make sure the plugin name matches the markdown file name.`
`⚠️ Could not find markdown documentation file for "${pluginName}". Make sure the plugin name matches the markdown file name.`,
)
return
}
Expand Down
10 changes: 5 additions & 5 deletions private/locale-pack/test.mjs
Expand Up @@ -76,7 +76,7 @@ function getAllFilesPerPlugin (pluginNames) {

if (name in pluginLocaleDependencies) {
filesPerPlugin[name] = filesPerPlugin[name].concat(
getFiles(pluginLocaleDependencies[name])
getFiles(pluginLocaleDependencies[name]),
)
}
}
Expand All @@ -93,14 +93,14 @@ async function unused (filesPerPlugin, data) {
'@uppy',
name,
'src',
'locale.js'
'locale.js',
)
const locale = (await import(localePath)).default

for (const key of Object.keys(locale.strings)) {
const regPat = new RegExp(
`(i18n|i18nArray)\\([^\\)]*['\`"]${key}['\`"]`,
'g'
'g',
)
if (!fileString.match(regPat)) {
return Promise.reject(new Error(`Unused locale key "${key}" in @uppy/${name}`))
Expand Down Expand Up @@ -136,7 +136,7 @@ function warnings ({ leadingLocale, followerLocales }) {
`${chalk.cyan(name)} locale has missing string: '${chalk.red(key)}'`,
`that is present in ${chalk.cyan(leadingLocaleName)}`,
`with value: ${chalk.yellow(value)}`,
].join(' ')
].join(' '),
)
}

Expand All @@ -150,7 +150,7 @@ function warnings ({ leadingLocale, followerLocales }) {
`${chalk.cyan(name)} locale has excess string:`,
`'${chalk.yellow(key)}' that is not present`,
`in ${chalk.cyan(leadingLocaleName)}.`,
].join(' ')
].join(' '),
)
}
}
Expand Down

0 comments on commit 66692cc

Please sign in to comment.