我已经安装eslint为我的 create-react-app 项目的开发依赖项。我这样做是为了
1) 通过 husky 和 lint-staged 运行 eslint 作为预提交检查
2) 使用 airbnb 和更漂亮的 lint 配置扩展 CRA 的 eslint
我收到警告:
Manually installing incompatible versions is known to cause hard-to-debug issues ...
Run Code Online (Sandbox Code Playgroud)
我只是想知道手动安装 eslint 是否真的有任何风险?或者我可以“安全地忽略”这个警告吗?(通过 SKIP_PREFLIGHT_CHECK=true)
假设我实现了一个简单的全局加载状态,如下所示:
// hooks/useLoading.js
import React, { createContext, useContext, useReducer } from 'react';
const Context = createContext();
const { Provider } = Context;
const initialState = {
isLoading: false,
};
function reducer(state, action) {
switch (action.type) {
case 'SET_LOADING_ON': {
return {
...state,
isLoading: true,
};
}
case 'SET_LOADING_OFF': {
return {
...state,
isLoading: false,
};
}
}
}
export const actionCreators = {
setLoadingOn: () => ({
type: 'SET_LOADING_ON',
}),
setLoadingOff: () => ({
type: 'SET_LOADING_OFF',
}),
};
export const …Run Code Online (Sandbox Code Playgroud)