Jsem začátečník v Reagovat rozvoje.
Snažím se vyřešit všechny chyby/varování mého projektu, ale I získat různé výsledky mezi vývojové prostředí a prostředí výroby. Nechtěl jsem, aby mezi nimi žádný rozdíl v konfiguraci.
Běží npm run lint
mi dává tento výstup:
npm spustit lint
Běží npm run build
mi dává tento výstup:
npm spustit build
Je to normální, že jsem si různé ESLint výstupy?
Tady je můj balíček.json:
{
"name": "immersion-dashboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.5.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.7",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.0",
"react-scripts": "4.0.3",
"typescript": "~4.1.5"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.2.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "^7.0.4",
"lint-staged": "^12.0.2",
"prettier": "^2.4.1"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:staged": "cross-env CI=true react-scripts test --env=jsdom --passWithNoTests",
"eject": "react-scripts eject",
"typescript": "tsc --project tsconfig.json --noEmit",
"prettier": "prettier . --write",
"lint": "eslint . --ext .ts --ext .tsx --fix",
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.{ts,tsx,json,css}": "prettier --write",
"*.{ts,tsx}": [
"eslint --fix",
"npm run test:staged"
]
}
}
a můj .eslintrc.json:
{
"env": {
"browser": true,
"es2021": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"airbnb",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "jest"],
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never"
}
],
"react/jsx-filename-extension": [
"warn",
{
"extensions": [".tsx"]
}
],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"no-param-reassign": [
"error",
{
"props": false
}
],
"no-console": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}