Solution to prompt “cannot find module ‘eslint config defaults / configurations / eslint'” when submitting with Git

The problem background
Dva application code git commits, vscode tips “always find module ‘eslint – config – defaults/configurations/eslint’ Referenced from: c: \ Users \ \. XXX eslintrc
Cause analysis,
Use eslintrc syntax check module dva application in git commits vscode will from the project component and its parent directory (English ancestors) looking for local. Eslintrc file (eslint configuration file).
If the file is not found, the C: /Users/ XXX /.eslintrc file is sought (this is the global configuration file).
Let’s open a global file like this

{
	/* See all the pre-defined configs here: https://www.npmjs.com/package/eslint-config-defaults */
	"extends": "defaults/configurations/eslint",
	"parser": "babel-eslint",
	"ecmaFeatures": {
		"jsx": true
	},
	"plugins": [
		"react"
	],
	"env": {
		"amd": true,
		"browser": true,
		"jquery": true,
		"node": true,
		"es6": true,
		"worker": true
	},
	"rules": {

		"eqeqeq": 2,
		"comma-dangle": 1,
		"no-console": 0,
		"no-debugger": 1,
		"no-extra-semi": 1,
		"no-extra-parens": 1,
		"no-irregular-whitespace": 0,
		"no-undef": 0,
		"no-unused-vars": 0,
		"semi": 1,
		"semi-spacing": 1,
		"valid-jsdoc": [
			2,
			{ "requireReturn": false }
		],

		"react/display-name": 2,
		"react/forbid-prop-types": 1,
		"react/jsx-boolean-value": 1,
		"react/jsx-closing-bracket-location": 1,
		"react/jsx-curly-spacing": 1,
		"react/jsx-indent-props": 1,
		"react/jsx-max-props-per-line": 0,
		"react/jsx-no-duplicate-props": 1,
		"react/jsx-no-literals": 0,
		"react/jsx-no-undef": 1,
		"react/jsx-sort-prop-types": 1,
		"react/jsx-sort-props": 0,
		"react/jsx-uses-react": 1,
		"react/jsx-uses-vars": 1,
		"react/no-danger": 1,
		"react/no-did-mount-set-state": 1,
		"react/no-did-update-set-state": 1,
		"react/no-direct-mutation-state": 1,
		"react/no-multi-comp": 1,
		"react/no-set-state": 0,
		"react/no-unknown-property": 1,
		"react/prop-types":0,
		"react/react-in-jsx-scope": 0,
		"react/require-extension": 1,
		"react/self-closing-comp": 1,
		"react/sort-comp": 1,
		"react/wrap-multilines": 1
	}
}

As you can see, the file references defaults/configurations/eslint; This error is usually reported because the project does not have the module referenced in the configuration file installed.
The solution
Method 1,
Still using eslint, installing ‘eslint – config – defaults/configurations/eslint’ module;
See https://www.npmjs.com/package/eslint-config-defaults;
NPM instruction

npm install --save-dev eslint eslint-config-defaults

There are many syntax errors when git is committed. These rules are defined by the Eslint configuration file. Just follow the change
Method 2,
Delete the global configuration file and add the local.eslintrc file in the project root. The file content can be customized to their own needs to modify the content; Such as the following is my own version; Just umi; There is no reference to the error module, while avoiding the tedious grammar check (of course, it is not recommended to do this, it helps to ensure the code style in the collaborative development process is unified and easy to maintain);

{
  "extends": "umi"
}

 

Read More: