Add some eslint rules, refer to: https://github.com/casdoor/casdoor/pull/973
This commit is contained in:
parent
f9221e7a81
commit
c6a130039c
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
build
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"stylelint-config-standard",
|
||||||
|
"stylelint-config-recommended-less"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"edge": "17",
|
||||||
|
"firefox": "60",
|
||||||
|
"chrome": "67",
|
||||||
|
"safari": "11.1"
|
||||||
|
},
|
||||||
|
"useBuiltIns": "usage",
|
||||||
|
"corejs": "3.6.5"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
|
@ -34,16 +34,17 @@
|
||||||
"xlsx": "^0.16.9"
|
"xlsx": "^0.16.9"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "set PORT=13001 && craco start",
|
"start": "cross-env PORT=13001 craco start",
|
||||||
"build": "del build.zip 2>nul && set \"GENERATE_SOURCEMAP=false\" && set \"SKIP_PREFLIGHT_CHECK=true\" && craco build && 360zip.exe -ar build %cd%/build.zip || ECHO.",
|
"build": "craco build",
|
||||||
"test": "craco test",
|
"test": "craco test",
|
||||||
"eject": "craco eject",
|
"eject": "craco eject",
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'"
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
|
"preinstall": "node -e \"if (process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('Use yarn for installing: https://yarnpkg.com/en/docs/install')\"",
|
||||||
|
"fix": "eslint --fix src/**/*.{js,jsx,ts,tsx}",
|
||||||
|
"lint:css": "stylelint src/**/*.{css,less} --fix"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": "react-app"
|
||||||
"react-app"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
|
@ -58,5 +59,31 @@
|
||||||
"last 1 safari version",
|
"last 1 safari version",
|
||||||
"ie 9, ie 10, ie 11"
|
"ie 9, ie 10, ie 11"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.18.13",
|
||||||
|
"@babel/eslint-parser": "^7.18.9",
|
||||||
|
"@babel/preset-react": "^7.18.6",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"eslint": "8.22.0",
|
||||||
|
"eslint-plugin-react": "^7.31.1",
|
||||||
|
"husky": "^4.3.8",
|
||||||
|
"lint-staged": "^13.0.3",
|
||||||
|
"stylelint": "^14.11.0",
|
||||||
|
"stylelint-config-recommended-less": "^1.0.4",
|
||||||
|
"stylelint-config-standard": "^28.0.0"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"src/**/*.{css,less}": [
|
||||||
|
"stylelint --fix"
|
||||||
|
],
|
||||||
|
"src/**/*.{js,jsx,ts,tsx}": [
|
||||||
|
"eslint --fix"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "lint-staged"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
it("renders without crashing", () => {
|
it("renders without crashing", () => {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
ReactDOM.render(<App />, div);
|
ReactDOM.render(<App />, div);
|
||||||
|
|
|
@ -10,7 +10,7 @@ class DataChart extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
fetch(this.props.url, {
|
fetch(this.props.url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}).then(res => res.text())
|
}).then(res => res.text())
|
||||||
|
|
|
@ -113,8 +113,8 @@ class FileTree extends React.Component {
|
||||||
});
|
});
|
||||||
|
|
||||||
const uploadFileType = e.target.value;
|
const uploadFileType = e.target.value;
|
||||||
console.log(this.state.file);
|
// console.log(this.state.file);
|
||||||
console.log(this.state.info);
|
// console.log(this.state.info);
|
||||||
|
|
||||||
const newInfo = Setting.deepCopy(this.state.info);
|
const newInfo = Setting.deepCopy(this.state.info);
|
||||||
if (uploadFileType !== "Other") {
|
if (uploadFileType !== "Other") {
|
||||||
|
|
|
@ -73,9 +73,9 @@ class VideoListPage extends React.Component {
|
||||||
|
|
||||||
uploadFile(info) {
|
uploadFile(info) {
|
||||||
const {status, response: res} = info.file;
|
const {status, response: res} = info.file;
|
||||||
if (status !== "uploading") {
|
// if (status !== "uploading") {
|
||||||
console.log(info.file, info.fileList);
|
// console.log(info.file, info.fileList);
|
||||||
}
|
// }
|
||||||
if (status === "done") {
|
if (status === "done") {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
Setting.showMessage("success", "上传视频成功");
|
Setting.showMessage("success", "上传视频成功");
|
||||||
|
|
|
@ -11,12 +11,11 @@ const resources = {
|
||||||
|
|
||||||
function initLanguage() {
|
function initLanguage() {
|
||||||
let language = localStorage.getItem("language");
|
let language = localStorage.getItem("language");
|
||||||
if (language === undefined || language == null) {
|
if (language === undefined || language === null) {
|
||||||
if (Conf.ForceLanguage !== "") {
|
if (Conf.ForceLanguage !== "") {
|
||||||
language = Conf.ForceLanguage;
|
language = Conf.ForceLanguage;
|
||||||
} else {
|
} else {
|
||||||
let userLanguage;
|
const userLanguage = navigator.language;
|
||||||
userLanguage = navigator.language;
|
|
||||||
switch (userLanguage) {
|
switch (userLanguage) {
|
||||||
case "zh-CN":
|
case "zh-CN":
|
||||||
language = "zh";
|
language = "zh";
|
||||||
|
|
|
@ -41,6 +41,7 @@ export function register(config) {
|
||||||
// Add some additional logging to localhost, pointing developers to the
|
// Add some additional logging to localhost, pointing developers to the
|
||||||
// service worker/PWA documentation.
|
// service worker/PWA documentation.
|
||||||
navigator.serviceWorker.ready.then(() => {
|
navigator.serviceWorker.ready.then(() => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
"This web app is being served cache-first by a service " +
|
"This web app is being served cache-first by a service " +
|
||||||
"worker. To learn more, visit https://bit.ly/CRA-PWA"
|
"worker. To learn more, visit https://bit.ly/CRA-PWA"
|
||||||
|
@ -60,7 +61,7 @@ function registerValidSW(swUrl, config) {
|
||||||
.then(registration => {
|
.then(registration => {
|
||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
if (installingWorker == null) {
|
if (installingWorker === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
installingWorker.onstatechange = () => {
|
installingWorker.onstatechange = () => {
|
||||||
|
@ -69,6 +70,7 @@ function registerValidSW(swUrl, config) {
|
||||||
// At this point, the updated precached content has been fetched,
|
// At this point, the updated precached content has been fetched,
|
||||||
// but the previous service worker will still serve the older
|
// but the previous service worker will still serve the older
|
||||||
// content until all client tabs are closed.
|
// content until all client tabs are closed.
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
"New content is available and will be used when all " +
|
"New content is available and will be used when all " +
|
||||||
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
|
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
|
||||||
|
@ -82,6 +84,7 @@ function registerValidSW(swUrl, config) {
|
||||||
// At this point, everything has been precached.
|
// At this point, everything has been precached.
|
||||||
// It's the perfect time to display a
|
// It's the perfect time to display a
|
||||||
// "Content is cached for offline use." message.
|
// "Content is cached for offline use." message.
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log("Content is cached for offline use.");
|
console.log("Content is cached for offline use.");
|
||||||
|
|
||||||
// Execute callback
|
// Execute callback
|
||||||
|
@ -94,6 +97,7 @@ function registerValidSW(swUrl, config) {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error("Error during service worker registration:", error);
|
console.error("Error during service worker registration:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -106,7 +110,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
const contentType = response.headers.get("content-type");
|
const contentType = response.headers.get("content-type");
|
||||||
if (
|
if (
|
||||||
response.status === 404 ||
|
response.status === 404 ||
|
||||||
(contentType != null && contentType.indexOf("javascript") === -1)
|
(contentType !== null && contentType.indexOf("javascript") === -1)
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
|
@ -120,6 +124,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
"No internet connection found. App is running in offline mode."
|
"No internet connection found. App is running in offline mode."
|
||||||
);
|
);
|
||||||
|
|
1586
web/yarn.lock
1586
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue