Skip to content

Commit

Permalink
Update Dependencies Resolution (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueleite42 authored Sep 11, 2021
1 parent 1f25981 commit 874b83f
Show file tree
Hide file tree
Showing 21 changed files with 1,154 additions and 843 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2018
},
"root": true,
"extends": "./src/common",
"ignorePatterns": ["doc/"]
Expand Down
6 changes: 2 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
Please check if your PR fulfills the following requirements:

- [ ] I have followed GitFlow pattern to create the branch
- [ ] I have added all the `peerDependencies` needed as `devDependencies` too
- [ ] I have added the new `peerDependecies` to the installation docs
- [ ] I have tested the updates and it works
- [ ] I have added all the plugins and configs as `dependencies`
- [ ] I have tested the updates using `yarn lk`, `yarn link @techmmunity/eslint-config` and checking in another project if it works

## PR Type

What kind of change does this PR introduce?

```
[ ] Hotfix
[ ] Bugfix
[ ] Feature
[ ] Documentation update
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
"eslintconfig",
"styleguide",
"passhref",
"polyfillio"
"polyfillio",
"rushstack",
"Guilded"
]
}
182 changes: 55 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Techmmunity Style Guide
<div align="center">
<img src="https://github.com/techmmunity/eslint-config/raw/master/resources/logo.gif" width="300" height="300">
</div>

[![Style Guide: Techmmunity](https://img.shields.io/badge/style%20guide-Techmmunity-01d2ce?style=flat)](https://github.com/techmmunity/eslint-config)
[![npm](https://img.shields.io/npm/v/@techmmunity/eslint-config.svg?color=CC3534)](https://www.npmjs.com/package/@techmmunity/eslint-config)
[![Downloads](https://img.shields.io/npm/dw/@techmmunity/eslint-config.svg)](https://www.npmjs.com/package/@techmmunity/eslint-config)
<div align="center">

# Techmmunity - Style Guide

[![Style Guide: Techmmunity](https://img.shields.io/badge/style%20guide-TECHMMUNITY-01d2ce?style=for-the-badge)](https://github.com/techmmunity/eslint-config)
[![npm](https://img.shields.io/npm/v/@techmmunity/eslint-config.svg?style=for-the-badge&color=CC3534)](https://www.npmjs.com/package/@techmmunity/eslint-config)
[![Downloads](https://img.shields.io/npm/dw/@techmmunity/eslint-config.svg?style=for-the-badge)](https://www.npmjs.com/package/@techmmunity/eslint-config)

</div>

In this package, you can find the **Techmmunity Style Guide**. We try to keep a clean and consistent code style, with modern features and using best practices.

Expand Down Expand Up @@ -42,11 +50,25 @@ In this package, you can find the **Techmmunity Style Guide**. We try to keep a
- Bye bye prettier: You don't need to be using the prettier extension for VSCode if you have this baby on your project
- Direct support: Join our discord community and get your questions answered

## Install

```sh
yarn add -D @techmmunity/eslint-config eslint prettier
```

or

```sh
npm i --save-dev @techmmunity/eslint-config eslint prettier
```

## Modules

**Alert:** After install any module, you must restart VSCode.
**Alert:** After any change at `eslintrc.json` file, you must restart VSCode.

This repository contains the best practices divided by languages, frameworks and tools. The currently existent modules are:
**Alert:** The **common module** must **ALWAYS** be extend, and must **ALWAYS** be the fist one.

This repository contains the best practices divided by libs, frameworks and tools. The currently existent modules are:

<!-- -->
<!-- -->
Expand All @@ -60,22 +82,6 @@ The common module is the default rules used by every javascript project. It does

**Tip:** You can see an example project [here](https://github.com/techmmunity/eslint-config/blob/master/doc/example-project-common)

#### Install

As the ESLint plugins are loaded from the user's project and not from the package project, you also must install the package and all it's **peerDependencies** all the plugins used by this package.

```sh
yarn add -D @techmmunity/eslint-config \
eslint \
prettier \
eslint-plugin-import \
eslint-plugin-import-helpers \
eslint-plugin-sonarjs \
eslint-plugin-filenames \
eslint-plugin-prefer-arrow \
eslint-plugin-prettier
```

#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:
Expand All @@ -99,17 +105,6 @@ Create an `.eslintrc.json` file in the root folder of your package and add this

Specific configs to projects that uses Jest.

#### Depends on

- Common Module

#### Install

```sh
yarn add -D eslint-plugin-jest \
eslint-plugin-jest-formatting
```

#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:
Expand All @@ -118,7 +113,7 @@ Create an `.eslintrc.json` file in the root folder of your package and add this
{
"root": true,
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/jest"
]
}
Expand All @@ -136,17 +131,6 @@ Create an `.eslintrc.json` file in the root folder of your package and add this

Specific configs to projects that uses NextJs.

#### Depends on

- Common Module
- React Module

#### Install

```sh
yarn add -D @next/eslint-plugin-next
```

#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:
Expand All @@ -155,8 +139,7 @@ Create an `.eslintrc.json` file in the root folder of your package and add this
{
"root": true,
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/react", // You must extend the react module too!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/nextjs"
]
}
Expand All @@ -174,17 +157,6 @@ Create an `.eslintrc.json` file in the root folder of your package and add this

Specific configs to projects that uses React.

#### Depends on

- Common Module

#### Install

```sh
yarn add -D eslint-plugin-react \
eslint-plugin-react-hooks
```

#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:
Expand All @@ -193,7 +165,7 @@ Create an `.eslintrc.json` file in the root folder of your package and add this
{
"root": true,
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/react"
]
}
Expand All @@ -211,40 +183,15 @@ Create an `.eslintrc.json` file in the root folder of your package and add this

Specific configs to projects that uses NextJs with TypeScript.

#### Depends on

- Common Module
- React Module
- NextJs Module
- TS-React Module
- TypeScript Module

#### Install

> Doesn't use any additional packages
#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:

```json
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/react", // You must extend the react module too!
"@techmmunity/eslint-config/nextjs", // You must extend the nextjs module too!
"@techmmunity/eslint-config/typescript", // You must extend the typescript module too!
"@techmmunity/eslint-config/ts-react", // You must extend the react module too!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/ts-nextjs"
]
}
Expand All @@ -262,36 +209,15 @@ Create an `.eslintrc.json` file in the root folder of your package and add this

Specific configs to projects that uses React with TypeScript.

#### Depends on

- Common Module
- React Module
- TypeScript Module

#### Install

> Doesn't use any additional packages
#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:

```json
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/react", // You must extend the react module too!
"@techmmunity/eslint-config/typescript", // You must extend the typescript module too!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/ts-react"
]
}
Expand All @@ -313,50 +239,52 @@ Specific configs for typescript projects.

- Common Module

#### Install

```sh
yarn add -D @typescript-eslint/eslint-plugin \
@typescript-eslint/parser
```

#### Usage

Create an `.eslintrc.json` file in the root folder of your package and add this content to it:

```json
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be the first!
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/typescript"
]
}
```

</details>

## WARNINGS
## Combining Modules

### Working with TypeScript
You can safely combine some modules, like this:

If you work with typescript, you will face the error `Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.` in some files. Fix it is very simple: **You need to include these files in the "include" of tsconfig.json file**
```json
{
"root": true,
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/typescript",
"@techmmunity/eslint-config/jest"
]
}
```

Example:
But in some cases, where that module is already imported, it will cause a conflict, like in this case:

```json
// tsconfig.json

{
"includes": ["next.config.js"]
"root": true,
"extends": [
"@techmmunity/eslint-config/common", // The common module always should be extended!
"@techmmunity/eslint-config/nextjs",
"@techmmunity/eslint-config/react" // The react module is already imported by the nextjs module, so it will cause a conflict
]
}
```

## Warnings

### Problems with Prettier

If you are using the VSCode Prettier Extension, you need to disable it, because this package already configs the prettier and uses it under the hood.
Expand Down
Loading

0 comments on commit 874b83f

Please sign in to comment.