mirror of
https://github.com/rust-lang/mdBook.git
synced 2025-12-27 07:54:20 -05:00
Merge pull request #2817 from ehuss/update-eslint-9
Update eslint to 9.34.0
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"module": "readonly",
|
||||
"require": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2021,
|
||||
"requireConfigFile": false,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"ignorePatterns": ["**min.js", "**/highlight.js", "**/playground_editor/*"],
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"brace-style": [
|
||||
"error",
|
||||
"1tbs",
|
||||
{ "allowSingleLine": false }
|
||||
],
|
||||
"curly": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"keyword-spacing": [
|
||||
"error",
|
||||
{ "before": true, "after": true }
|
||||
],
|
||||
"comma-spacing": [
|
||||
"error",
|
||||
{ "before": false, "after": true }
|
||||
],
|
||||
"arrow-spacing": [
|
||||
"error",
|
||||
{ "before": true, "after": true }
|
||||
],
|
||||
"key-spacing": [
|
||||
"error",
|
||||
{ "beforeColon": false, "afterColon": true, "mode": "strict" }
|
||||
],
|
||||
"func-call-spacing": ["error", "never"],
|
||||
"space-infix-ops": "error",
|
||||
"space-before-function-paren": ["error", "never"],
|
||||
"space-before-blocks": "error",
|
||||
"no-console": [
|
||||
"error",
|
||||
{ "allow": ["warn", "error"] }
|
||||
],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-style": ["error", "last"],
|
||||
"max-len": ["error", { "code": 100, "tabWidth": 2 }],
|
||||
"eol-last": ["error", "always"],
|
||||
"no-extra-parens": "error",
|
||||
"arrow-parens": ["error", "as-needed"],
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"prefer-const": ["error"],
|
||||
"no-var": "error",
|
||||
"eqeqeq": "error"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"tests/**/*.js"
|
||||
],
|
||||
"env": {
|
||||
"jest": true,
|
||||
"node": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -85,7 +85,6 @@ function playground_text(playground, hidden = true) {
|
||||
const re = /extern\s+crate\s+([a-zA-Z_0-9]+)\s*;/g;
|
||||
const snippet_crates = [];
|
||||
let item;
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (item = re.exec(txt)) {
|
||||
snippet_crates.push(item[1]);
|
||||
}
|
||||
@@ -351,7 +350,7 @@ aria-label="Show hidden lines"></button>';
|
||||
let theme = null;
|
||||
try {
|
||||
theme = localStorage.getItem('mdbook-theme');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ignore error.
|
||||
}
|
||||
return theme;
|
||||
@@ -412,7 +411,7 @@ aria-label="Show hidden lines"></button>';
|
||||
if (store) {
|
||||
try {
|
||||
localStorage.setItem('mdbook-theme', theme);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ignore error.
|
||||
}
|
||||
}
|
||||
@@ -560,7 +559,7 @@ aria-label="Show hidden lines"></button>';
|
||||
sidebar.setAttribute('aria-hidden', false);
|
||||
try {
|
||||
localStorage.setItem('mdbook-sidebar', 'visible');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore error.
|
||||
}
|
||||
}
|
||||
@@ -574,7 +573,7 @@ aria-label="Show hidden lines"></button>';
|
||||
sidebar.setAttribute('aria-hidden', true);
|
||||
try {
|
||||
localStorage.setItem('mdbook-sidebar', 'hidden');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore error.
|
||||
}
|
||||
}
|
||||
|
||||
72
eslint.config.mjs
Normal file
72
eslint.config.mjs
Normal file
@@ -0,0 +1,72 @@
|
||||
import { defineConfig, globalIgnores } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(["**/**min.js", "**/highlight.js", "**/playground_editor/*"]),
|
||||
{
|
||||
rules: {
|
||||
indent: ["error", 4],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
quotes: ["error", "single"],
|
||||
semi: ["error", "always"],
|
||||
|
||||
"brace-style": ["error", "1tbs", {
|
||||
allowSingleLine: false,
|
||||
}],
|
||||
|
||||
curly: "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-multi-spaces": "error",
|
||||
|
||||
"keyword-spacing": ["error", {
|
||||
before: true,
|
||||
after: true,
|
||||
}],
|
||||
|
||||
"comma-spacing": ["error", {
|
||||
before: false,
|
||||
after: true,
|
||||
}],
|
||||
|
||||
"arrow-spacing": ["error", {
|
||||
before: true,
|
||||
after: true,
|
||||
}],
|
||||
|
||||
"key-spacing": ["error", {
|
||||
beforeColon: false,
|
||||
afterColon: true,
|
||||
mode: "strict",
|
||||
}],
|
||||
|
||||
"func-call-spacing": ["error", "never"],
|
||||
"space-infix-ops": "error",
|
||||
"space-before-function-paren": ["error", "never"],
|
||||
"space-before-blocks": "error",
|
||||
|
||||
"no-console": ["error", {
|
||||
allow: ["warn", "error"],
|
||||
}],
|
||||
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-style": ["error", "last"],
|
||||
|
||||
"max-len": ["error", {
|
||||
code: 100,
|
||||
tabWidth: 2,
|
||||
}],
|
||||
|
||||
"eol-last": ["error", "always"],
|
||||
"no-extra-parens": "error",
|
||||
"arrow-parens": ["error", "as-needed"],
|
||||
|
||||
"no-unused-vars": ["error", {
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
}],
|
||||
|
||||
"prefer-const": ["error"],
|
||||
"no-var": "error",
|
||||
eqeqeq: "error",
|
||||
},
|
||||
},
|
||||
]);
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"browser-ui-test": "0.21.1",
|
||||
"eslint": "^8.57.1"
|
||||
"eslint": "^9.34.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint crates/mdbook-html/front-end/*js crates/mdbook-html/front-end/**/*js",
|
||||
"lint": "eslint --no-warn-ignored crates/mdbook-html/front-end/*js crates/mdbook-html/front-end/**/*js",
|
||||
"lint-fix": "eslint --fix crates/mdbook-html/front-end/*js crates/mdbook-html/front-end/**/*js"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user