AleksandrSerov / presets-lint

The easiest way to set up linters for your react application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation

To install all project dependencies, it is recommended to use install-peerdeps

npx install-peerdeps --dev @sserov/presets-lint

If you are currently using yarn you may have problems using install-peerdeps. Look at this issue. A workaround would be to use the version 1.11.0.

npx install-peerdeps@1.11.0 --dev @sserov/presets-lint

You can also supply all the necessary peerDependencies manually. For this, find out the required versions by command

npm info "@sserov/presets-lint@latest" peerDependencies

And add them to your project as dev dependency.

Configuration linters using package.json

{
    "prettier": "./node_modules/@sserov/presets-lint/prettier.js",
    "eslintConfig": {
        "extends": "./node_modules/@sserov/presets-lint/eslint.js"
    },
    "stylelint": {
        "extends": "./node_modules/@sserov/presets-lint/stylelint.js"
    },
    "commitlint": {
        "extends": ["./node_modules/@sserov/presets-lint/commitlint.js"]
    }
}

Configuration scripts for linters and formatters using package.json

{
    "scripts": {
        "lint:css": "stylelint ./src/**/*.css",
        "lint:scripts": "eslint \"**/*.{js,jsx,ts,tsx}\"",
        "lint": "yarn lint:css && yarn lint:scripts",
    }
}

Configuration simple-git-hooks and lint-staged:

{
	"lint-staged": {
		"**/*.{js,jsx,ts,tsx}": [
			"prettier-eslint --write",
			"eslint"
		],
		"**/*.css": [
			"prettier-eslint --write",
			"stylelint"
		]
	},
   	"simple-git-hooks": {
		"pre-commit": "npx lint-staged",
		"commit-msg": "npx commitlint -e"
	}
}

About

The easiest way to set up linters for your react application


Languages

Language:JavaScript 99.6%Language:CSS 0.4%