Skip to content

Commit

Permalink
feat: remove eslint-plugin-prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Oct 15, 2020
1 parent c2c558a commit 904663e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tests
*.log
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <em><b>ESLINT-CONFIG-WELLY</b></em>

ESlint configuration for my personal [React](https://reactjs.org) projects, which integrates [TypeScript](https://www.typescriptlang.org), [Prettier](https://prettier.io), and [more](#whats-inside).
ESlint configuration for my personal [React](https://reactjs.org) projects, which integrates [TypeScript](https://www.typescriptlang.org), [Compat](https://github.com/amilajack/eslint-plugin-compat), and [more](#whats-inside).

[![build status](https://img.shields.io/github/workflow/status/wellyshen/eslint-config-welly/CI?style=flat-square)](https://github.com/wellyshen/eslint-config-welly/actions?query=workflow%3ACI)
[![npm version](https://img.shields.io/npm/v/eslint-config-welly?style=flat-square)](https://www.npmjs.com/package/eslint-config-welly)
Expand All @@ -15,7 +15,7 @@ ESlint configuration for my personal [React](https://reactjs.org) projects, whic

## Installation

This package is distributed via [npm](https://www.npmjs.com/package/eslint-config-welly). It requires [eslint](https://github.com/eslint/eslint), [typescript](https://github.com/microsoft/TypeScript), and [prettier](https://github.com/prettier/prettier).
This package is distributed via [npm](https://www.npmjs.com/package/eslint-config-welly). It requires [eslint](https://github.com/eslint/eslint) and [typescript](https://github.com/microsoft/TypeScript).

Install the correct version of each package, which are listed by the command:

Expand All @@ -32,9 +32,9 @@ npx install-peerdeps --dev eslint-config-welly
Or install each package by yourself:

```sh
npm install --save-dev eslint-config-welly eslint@^x.x.x prettier@^x.x.x typescript@^x.x.x
npm install --save-dev eslint-config-welly eslint@^x.x.x typescript@^x.x.x
# or
yarn add --dev eslint-config-welly eslint@^x.x.x prettier@^x.x.x typescript@^x.x.x
yarn add --dev eslint-config-welly eslint@^x.x.x typescript@^x.x.x
```

## Usage
Expand All @@ -50,6 +50,18 @@ module.exports = {
};
```

## Eliminate Prettier Conflicts for You

[Prettier](https://prettier.io) is a great code formatter, I highly recommend you guys give it a try. This package built-ins the [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) for you, all you need to do is setup the [Prettier CLI](https://prettier.io/docs/en/cli.html) to use it.

```json
// package.json

"format": "prettier --check ."
// or
"format": "prettier --write ."
```

## What's Inside?

This configuration contains the following cool packages.
Expand All @@ -62,7 +74,7 @@ This configuration contains the following cool packages.
| [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks) | This ESLint plugin enforces the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html). | |
| [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) | ESLint plugin with rules that help validate proper imports. | |
| [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) | Static AST checker for a11y rules on JSX elements. | |
| [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) | ESLint plugin for Prettier formatting. | |
| [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) | Turns off all rules that are unnecessary or might conflict with Prettier. | Dynamic enabled |
| [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) | Lint the browser compatibility of your code. | |
| [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) | ESLint plugin for [Jest](https://jestjs.io). | |
| [eslint-plugin-jest-dom](https://github.com/testing-library/eslint-plugin-jest-dom) | ESLint rules for use with [jest-dom](https://testing-library.com/docs/ecosystem-jest-dom). | Dynamic enabled |
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const readPkgUp = require("read-pkg-up");

let hasPrettier = false;
let hasJestDom = false;
let hasTestingLibrary = false;
let hasEmotion = false;
Expand All @@ -13,6 +14,7 @@ try {
...packageJson.dependencies,
});

hasPrettier = allDeps.includes("prettier");
hasJestDom = allDeps.includes("@testing-library/jest-dom");
hasTestingLibrary =
allDeps.includes("@testing-library/react") ||
Expand All @@ -38,17 +40,16 @@ module.exports = {
"plugin:jest/style",
hasJestDom && "plugin:jest-dom/recommended",
hasTestingLibrary && "plugin:testing-library/react",
"plugin:prettier/recommended",
"prettier/@typescript-eslint",
"prettier/react",
hasPrettier && "prettier",
hasPrettier && "prettier/@typescript-eslint",
hasPrettier && "prettier/react",
].filter(Boolean),
plugins: [
"@typescript-eslint",
"jest",
hasJestDom && "jest-dom",
hasTestingLibrary && "testing-library",
hasEmotion && "emotion",
"prettier",
].filter(Boolean),
settings: {
"import/resolver": {
Expand Down Expand Up @@ -83,6 +84,5 @@ module.exports = {
"emotion/styled-import": "error",
}
: null),
"prettier/prettier": "error",
},
};
2 changes: 2 additions & 0 deletions linter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

const config = require("./index");
config.rules["jest/no-deprecated-functions"] = "off";
module.exports = config;
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-welly",
"version": "1.4.12",
"version": "1.5.0",
"description": "ESLint configuration for React projects that I do. Feel free to use this!",
"license": "MIT",
"homepage": "https://github.com/wellyshen/eslint-config-welly",
Expand All @@ -26,7 +26,9 @@
],
"scripts": {
"test": "eslint tests/*",
"lint": "eslint --fix index.js",
"lint": "yarn lint:code && yarn lint:format",
"lint:code": "eslint --fix index.js",
"lint:format": "prettier -w . -u --loglevel silent",
"preversion": "yarn lint",
"postversion": "git push --follow-tags --no-verify && npm publish"
},
Expand All @@ -37,7 +39,7 @@
},
"lint-staged": {
"index.js": "eslint --fix",
"**/*": "prettier --write --ignore-unknown"
"**/*": "prettier -w -u"
},
"eslintConfig": {
"extends": "./linter.js"
Expand All @@ -54,7 +56,6 @@
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jest-dom": "^3.2.3",
"eslint-plugin-jsx-a11y": "^6.3.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4",
"eslint-plugin-testing-library": "^3.9.1",
Expand All @@ -67,7 +68,6 @@
},
"peerDependencies": {
"eslint": "^7.2.0",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
},
"engines": {
Expand Down

0 comments on commit 904663e

Please sign in to comment.