chore(eslint): More work on the root .eslintrc
* Remove the site-specific and `packages/new-design`-specific `.eslintrc` files * Use `eslint-config-next` where appropriate (this fixes linting for sites/shared, bringing it in line with the other sites) * Be more strict about which envs/globals are allowed in any given JavaScript file; assume none by default.
This commit is contained in:
parent
95be9f6ea1
commit
1430d48910
8 changed files with 58 additions and 55 deletions
|
@ -1,7 +1,25 @@
|
|||
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/**',
|
||||
]
|
||||
const frontendFiles = [
|
||||
'**/components/**',
|
||||
'**/hooks/**',
|
||||
'**/pages/**',
|
||||
'**/page-templates/**',
|
||||
]
|
||||
|
||||
module.exports = {
|
||||
extends: 'eslint:recommended',
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
// Required when using experimental EcmaScript features
|
||||
|
@ -17,13 +35,48 @@ module.exports = {
|
|||
},
|
||||
rules: {},
|
||||
overrides: [
|
||||
// JavaScript source files
|
||||
// Partitioned JavaScript files
|
||||
{
|
||||
files: nodeFiles,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: frontendFiles,
|
||||
excludedFiles: nodeFiles,
|
||||
extends: ['next/core-web-vitals'],
|
||||
env: {
|
||||
// We can be stricter than 'next/core-web-vitals' is
|
||||
node: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: '**',
|
||||
excludedFiles: [].concat(nodeFiles, frontendFiles),
|
||||
env: {
|
||||
'shared-node-browser': true,
|
||||
},
|
||||
},
|
||||
// Additional globals for JavaScript files that happen to be CommonJS.
|
||||
// Only allowed in *.cjs files, not *.js files, because we probably want to move towards
|
||||
// a `"type": "module"` future where any CommonJS files would have to have .cjs extensions.
|
||||
{
|
||||
files: ['**/*.cjs'],
|
||||
env: {
|
||||
commonjs: true,
|
||||
},
|
||||
},
|
||||
// Additional globals for JavaScript files that happen to contain Mocha tests
|
||||
{
|
||||
files: ['**/tests/**', '**/*.test.mjs'],
|
||||
env: {
|
||||
mocha: true,
|
||||
},
|
||||
},
|
||||
|
||||
// JSON files
|
||||
{
|
||||
|
@ -41,7 +94,7 @@ module.exports = {
|
|||
|
||||
// Markdown files
|
||||
{
|
||||
files: ['**/*.md'],
|
||||
files: ['**/markdown/**', '**/*.md'],
|
||||
plugins: ['markdown'],
|
||||
processor: 'markdown/markdown',
|
||||
},
|
||||
|
@ -56,10 +109,4 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
],
|
||||
globals: {
|
||||
it: 'readonly',
|
||||
describe: 'readonly',
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
"esbuild": "^0.15.3",
|
||||
"esbuild-plugin-yaml": "^0.0.1",
|
||||
"eslint": "^8.23.1",
|
||||
"eslint-config-next": "^12.3.1",
|
||||
"eslint-plugin-jsonc": "^2.4.0",
|
||||
"eslint-plugin-markdown": "^3.0.0",
|
||||
"eslint-plugin-yaml": "^0.5.0",
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
extends: eslint:recommended
|
||||
overrides:
|
||||
- files: ["*.yaml", "*.yml"]
|
||||
plugins: ["yaml"]
|
||||
extends: ["plugin:yaml/recommended"]
|
||||
parserOptions:
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
rules: {}
|
||||
globals:
|
||||
it: readonly
|
||||
describe: readonly
|
||||
process: readonly
|
||||
__dirname: readonly
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
extends:
|
||||
- eslint:recommended
|
||||
- plugin:react/recommended
|
||||
overrides: []
|
||||
parserOptions:
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
plugins:
|
||||
- react
|
||||
rules:
|
||||
react/prop-types: off
|
||||
react/react-in-jsx-scope: off
|
||||
globals:
|
||||
module: readonly
|
||||
|
|
@ -7823,7 +7823,7 @@ escodegen@^2.0.0:
|
|||
optionalDependencies:
|
||||
source-map "~0.6.1"
|
||||
|
||||
eslint-config-next@12.3.1:
|
||||
eslint-config-next@12.3.1, eslint-config-next@^12.3.1:
|
||||
version "12.3.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.3.1.tgz#5d4eb0b7903cea81fd0d5106601d3afb0a453ff4"
|
||||
integrity sha512-EN/xwKPU6jz1G0Qi6Bd/BqMnHLyRAL0VsaQaWA7F3KkjAgZHi4f1uL1JKGWNxdQpHTW/sdGONBd0bzxUka/DJg==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue