1
0
Fork 0

fix(eslint): Improve the globs for JS files

* Explicitly match file extensions in all globs, thus preventing eslint from trying to run on unsupported file types.
  * Include the defaults: `.js`, `.mjs`, and `.cjs`
  * Include`.jsx`
  * Include `.mustache`, since there are a couple JS template files with that suffix.
* Fix some incorrect globs (`**.js` -> `**/*.js`) which were the source of some unexpected lint failures.
This commit is contained in:
Nikhil Chelliah 2022-10-12 19:08:26 -04:00
parent d16bc9afff
commit 76d2778195

View file

@ -1,22 +1,24 @@
const mongoFiles = ['ansible/playbooks/files/migrate_data.{js,mjs,cjs}']
const jsSuffixes = '{js,mjs,cjs,jsx}'
const mongoFiles = [`ansible/playbooks/files/migrate_data.${jsSuffixes}`]
const nodeFiles = [
'**/build.dflt.{js,mjs,cjs}',
'**/build.{js,mjs,cjs}',
'**/config/**',
'**/prebuild.{js,mjs,cjs}',
'**/prebuild/**',
'**/scripts/**',
'packages/new-design/lib/**',
'sites/backend/**',
'sites/*/mdx/**',
'sites/*/themes/**',
`**/build.dflt.${jsSuffixes}`,
`**/build.${jsSuffixes}`,
`**/config/**/*.${jsSuffixes}`,
`**/prebuild.${jsSuffixes}`,
`**/prebuild/**/*.${jsSuffixes}`,
`**/scripts/**/*.${jsSuffixes}`,
`packages/new-design/lib/**/*.${jsSuffixes}`,
`sites/backend/**/*.${jsSuffixes}`,
`sites/*/mdx/**/*.${jsSuffixes}`,
`sites/*/themes/**/*.${jsSuffixes}`,
]
const frontendFiles = [
'**/components/**',
'**/hooks/**',
'**/pages/**',
'**/page-templates/**',
'packages/i18n/**/*.md/*.js',
`**/components/**/*.${jsSuffixes}`,
`**/hooks/**/*.${jsSuffixes}`,
`**/pages/**/*.${jsSuffixes}`,
`**/page-templates/**/*.${jsSuffixes}`,
`packages/i18n/**/*.md/*.${jsSuffixes}`,
]
module.exports = {
@ -64,7 +66,7 @@ module.exports = {
},
},
{
files: ['**'],
files: [`**/*.${jsSuffixes}{,.mustache}`],
excludedFiles: [].concat(mongoFiles, nodeFiles, frontendFiles),
env: {
'shared-node-browser': true,
@ -81,7 +83,7 @@ module.exports = {
},
// Additional globals for JavaScript files that happen to contain Mocha tests
{
files: ['**/tests/**', '**/*.test.mjs'],
files: [`**/tests/**/*.${jsSuffixes}`, `**/*.test.${jsSuffixes}`],
env: {
mocha: true,
},
@ -89,7 +91,7 @@ module.exports = {
// JSON files
{
files: ['*.json', '*.json5', '*.jsonc'],
files: ['**/*.{json,json5,jsonc}{,.mustache}'],
extends: ['plugin:jsonc/recommended-with-jsonc'],
parser: 'jsonc-eslint-parser',
},