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:
parent
d16bc9afff
commit
76d2778195
1 changed files with 21 additions and 19 deletions
|
@ -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 = [
|
const nodeFiles = [
|
||||||
'**/build.dflt.{js,mjs,cjs}',
|
`**/build.dflt.${jsSuffixes}`,
|
||||||
'**/build.{js,mjs,cjs}',
|
`**/build.${jsSuffixes}`,
|
||||||
'**/config/**',
|
`**/config/**/*.${jsSuffixes}`,
|
||||||
'**/prebuild.{js,mjs,cjs}',
|
`**/prebuild.${jsSuffixes}`,
|
||||||
'**/prebuild/**',
|
`**/prebuild/**/*.${jsSuffixes}`,
|
||||||
'**/scripts/**',
|
`**/scripts/**/*.${jsSuffixes}`,
|
||||||
'packages/new-design/lib/**',
|
`packages/new-design/lib/**/*.${jsSuffixes}`,
|
||||||
'sites/backend/**',
|
`sites/backend/**/*.${jsSuffixes}`,
|
||||||
'sites/*/mdx/**',
|
`sites/*/mdx/**/*.${jsSuffixes}`,
|
||||||
'sites/*/themes/**',
|
`sites/*/themes/**/*.${jsSuffixes}`,
|
||||||
]
|
]
|
||||||
const frontendFiles = [
|
const frontendFiles = [
|
||||||
'**/components/**',
|
`**/components/**/*.${jsSuffixes}`,
|
||||||
'**/hooks/**',
|
`**/hooks/**/*.${jsSuffixes}`,
|
||||||
'**/pages/**',
|
`**/pages/**/*.${jsSuffixes}`,
|
||||||
'**/page-templates/**',
|
`**/page-templates/**/*.${jsSuffixes}`,
|
||||||
'packages/i18n/**/*.md/*.js',
|
`packages/i18n/**/*.md/*.${jsSuffixes}`,
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -64,7 +66,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['**'],
|
files: [`**/*.${jsSuffixes}{,.mustache}`],
|
||||||
excludedFiles: [].concat(mongoFiles, nodeFiles, frontendFiles),
|
excludedFiles: [].concat(mongoFiles, nodeFiles, frontendFiles),
|
||||||
env: {
|
env: {
|
||||||
'shared-node-browser': true,
|
'shared-node-browser': true,
|
||||||
|
@ -81,7 +83,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
// Additional globals for JavaScript files that happen to contain Mocha tests
|
// Additional globals for JavaScript files that happen to contain Mocha tests
|
||||||
{
|
{
|
||||||
files: ['**/tests/**', '**/*.test.mjs'],
|
files: [`**/tests/**/*.${jsSuffixes}`, `**/*.test.${jsSuffixes}`],
|
||||||
env: {
|
env: {
|
||||||
mocha: true,
|
mocha: true,
|
||||||
},
|
},
|
||||||
|
@ -89,7 +91,7 @@ module.exports = {
|
||||||
|
|
||||||
// JSON files
|
// JSON files
|
||||||
{
|
{
|
||||||
files: ['*.json', '*.json5', '*.jsonc'],
|
files: ['**/*.{json,json5,jsonc}{,.mustache}'],
|
||||||
extends: ['plugin:jsonc/recommended-with-jsonc'],
|
extends: ['plugin:jsonc/recommended-with-jsonc'],
|
||||||
parser: 'jsonc-eslint-parser',
|
parser: 'jsonc-eslint-parser',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue