Skip to content

Commit

Permalink
chore: update swc core to 1.3.85 (#143)
Browse files Browse the repository at this point in the history
* SWC ESM module doesn't support the strict option

* SWC ESM also doesn't support ignoreDynamic

* Changeset

* Documentation improvements
  • Loading branch information
patricklafrance authored Sep 18, 2023
1 parent c613c7c commit 334088f
Show file tree
Hide file tree
Showing 36 changed files with 960 additions and 262 deletions.
9 changes: 9 additions & 0 deletions .changeset/three-meals-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@workleap/postcss-configs": patch
"@workleap/webpack-configs": patch
"@workleap/eslint-plugin": patch
"@workleap/tsup-configs": patch
"@workleap/swc-configs": patch
---

Updated to SWC 1.3.85
8 changes: 4 additions & 4 deletions docs/browserslist/configure-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ meta:

> Only setup [Browserslist](https://browsersl.ist/) for projects that are **emitting application bundles**. For example, a library project shouldn't include Browserslist but a web application project should.
## 1. Install the packages
## Install the packages

Open a terminal at the root of the project and install the following packages:

Expand All @@ -26,7 +26,7 @@ npm install -D @workleap/browserslist-config browserslist
```
+++

## 2. Configure Browserslist
## Configure Browserslist

First, create a configuration file named `.browserslistrc` at the root of the project:

Expand All @@ -44,7 +44,7 @@ Then, open the newly created file and extend the default configuration with the
extends @workleap/browserslist-config
```

### Custom browsers
## Support custom browsers

If you are encountering a situation that is not currently handled by `@workleap/browserslist-configs`, you can customize your configuration file to extend this library shared configurations with additional browser versions:

Expand All @@ -56,7 +56,7 @@ last 2 OperaMobile 12.1 versions

Refer to the [Browserslist documentation](https://github.com/browserslist/browserslist#full-list) for a full list of available queries.

## 4. Try it :rocket:
## Try it :rocket:

To test your new Browserslist configuration, open a terminal at the root of the project and execute the following command:

Expand Down
2 changes: 1 addition & 1 deletion docs/eslint/custom-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Please, don't update your project configuration to use single quotes :sweat_smil

## Add a plugin

You can add new rules from a third party [ESLint plugin](https://eslint.org/docs/latest/use/configure/plugins):
You can add configure additional rules from a third party [ESLint plugin](https://eslint.org/docs/latest/use/configure/plugins):

```json !#4,6-8 .eslintrc.json
{
Expand Down
8 changes: 4 additions & 4 deletions docs/eslint/integrate-vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ meta:

[ESLint VS Code extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) greatly improve the development experience by **automatically linting** the code as you type and **automatically formatting** the code according to your ESLint configuration whenever you save.

## 1. Install the ESLint extension
## Install ESLint extension

Open VS Code and install the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension.

## 2. Configure VS Code
## Configure VS Code

Then, add the following settings to your solution [VS Code settings file](https://code.visualstudio.com/docs/getstarted/settings):

Expand All @@ -30,11 +30,11 @@ Then, add the following settings to your solution [VS Code settings file](https:
}
```

## 3. Install the EditorConfig extension
## Install EditorConfig extension

Finally, install the [EditorConfig.EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) extension.

## 4. Try it :rocket:
## Try it :rocket:

Restart VS Code, open a JavaScript file, type invalid code (e.g. `var x = 0;`), then save. The code should have been formatted automatically (e.g. `const x = 0;`).

Expand Down
252 changes: 252 additions & 0 deletions docs/eslint/setup-monorepo-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
---
order: 90
label: Setup a monorepo 2
meta:
title: Configure a monorepo - ESLint
toc:
depth: 2-4
---

# Setup a monorepo

!!!warning
This monorepo setup is intended to be used with [PNPM workspaces](https://pnpm.io/workspaces). You may need a different setup for [NPM workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) or [Yarn workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) because by default, those package managers **hoist dependencies** rather than installing them in isolation like PNPM.
!!!

To lint a monorepo solution (**multiple projects** per repository), [ESLint](https://eslint.org/) must be setuped to lint the files at the root of the solution (the monorepo **workspace**) and the files of every project of the monorepo. Execute the following steps to setup ESLint for a monorepo solution.

## Setup the workspace

### Install the packages

Open a terminal at the root of the solution workspace (the **root** of the repository) and install the following packages:

+++ pnpm
```bash
pnpm add -D @workleap/eslint-plugin eslint typescript @typescript-eslint/parser
```
+++ yarn
```bash
yarn add -D @workleap/eslint-plugin eslint typescript @typescript-eslint/parser
```
+++ npm
```bash
npm install -D @workleap/eslint-plugin eslint typescript @typescript-eslint/parser
```
+++

### Configure ESLint

First, create a configuration file named `.eslintrc.json` at the root of the solution workspace:

``` !#8
workspace
├── packages
├──── app
├────── src
├──────── ...
├────── package.json
├── package.json
├── .eslintrc.json
```

Then, open the newly created file and extend the default configuration with the `monorepo-workspace` shared configurations:

```json !#4 .eslintrc.json
{
"$schema": "https://json.schemastore.org/eslintrc",
"root": true,
"extends": "plugin:@workleap/monorepo-workspace"
}
```

#### .eslintignore

ESLint can be configured to [ignore](https://eslint.org/docs/latest/use/configure/ignore) certain files and directories while linting by specifying one or more glob patterns.

To do so, first, create a `.eslintignore` file at the root of the solution workspace:

``` !#9
workspace
├── packages
├──── app
├────── src
├──────── ...
├────── package.json
├── package.json
├── .eslintrc.json
├── .eslintignore
```

Then, open the newly created file and paste the following ignore rules:

```bash .eslintignore
**/dist/*
node_modules
*.md
*.yml
*.yaml
```

### Configure indent style

ESLint offers [built-in rules](https://eslint.org/docs/latest/rules/indent) for configuring the indentation style of a codebase. However, there's a catch: when [VS Code auto-formatting](https://code.visualstudio.com/docs/editor/codebasics#_formatting) feature is enabled, it might conflict with the configured indentation rules if they are set differently.

To guarantee a consistent indentation, we recommend using [EditorConfig](https://editorconfig.org/) on the consumer side. With EditorConfig, the indent style can be configured in a single file and be applied consistently across various formatting tools, including ESlint and [VS Code](https://code.visualstudio.com/).

First, create a `.editorconfig` file at the root of the solution workspace:

``` !#10
workspace
├── packages
├──── app
├────── src
├──────── ...
├────── package.json
├── package.json
├── .eslintrc.json
├── .eslintignore
├── .editorconfig
```

Then, open the newly created file and paste the following configuration:

```bash .editorconfig
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
```

### Add a CLI script

At times, especially when running the CI build, it's useful to lint the entire solution using a single command. To do so, add the following script to your solution's workspace `package.json` file:

``` !#7
workspace
├── packages
├──── app
├────── src
├──────── ...
├────── package.json
├── package.json <------- (this one!)
├── .eslintrc.json
├── .eslintignore
├── .editorconfig
```

```json package.json
{
"lint:eslint:": "eslint . --max-warnings=1 --cache --cache-location node_modules/.cache/eslint"
}
```

> The script definition may vary depending of your needs and your application configuration. For example, you might want to specify specific file extensions such as `--ext .js,.ts,.tsx`.
## Setup a project

### Install the package

Open a terminal at the root of the project (`packages/app` for this example) and install the following package:

+++ pnpm
```bash
pnpm add -D @workleap/eslint-plugin
```
+++ yarn
```bash
yarn add -D @workleap/eslint-plugin
```
+++ npm
```bash
npm install -D @workleap/eslint-plugin
```
+++

### Configure ESLint

First, create a configuration file named `.eslintrc.json` at the root of the project:

``` !#7
workspace
├── packages
├──── app
├────── src
├──────── ...
├────── package.json
├────── .eslintrc.json
├── package.json
├── .eslintrc.json
├── .eslintignore
├── .editorconfig
```

Then, open the newly created file and extend the default configuration with one of the [shared configurations](/eslint/#available-configurations) provided by `@workleap/eslint-plugin` :point_down:

#### `web-application`

For an application developed with TypeScript and React, use the following configuration:

```json !#4 packages/app/.eslintrc.json
{
"$schema": "https://json.schemastore.org/eslintrc",
"root": true,
"extends": "plugin:@workleap/web-application"
}
```

#### `react-library`

For a TypeScript library developed **with** React, use the following configuration:

```json !#4 packages/app/.eslintrc.json
{
"$schema": "https://json.schemastore.org/eslintrc",
"root": true,
"extends": "plugin:@workleap/react-library"
}
```

#### `typescript-library`

For a TypeScript library developed **without** React, use the following configuration:

```json !#4 packages/app/.eslintrc.json
{
"$schema": "https://json.schemastore.org/eslintrc",
"root": true,
"extends": "plugin:@workleap/typescript-library"
}
```

## Custom configuration

New projects shouldn't have to customize the default configurations offered by `@workleap/eslint-plugin`. However, if you are in the process of **migrating** an existing project to use this library or encountering a challenging situation, refer to the [custom configuration](custom-configuration.md) page to understand how to override or extend the default configurations. Remember, **no locked in** :heart::v:.

## Try it :rocket:

To test your new ESLint setup, open a JavaScript file, type invalid code (e.g. `var x = 0;`), then save. Open a terminal at the root of the solution and execute the [CLI script added earlier](#add-a-cli-script):

+++ pnpm
```bash
pnpm lint:eslint
```
+++ yarn
```bash
yarn lint:eslint
```
+++ npm
```bash
npm run lint:eslint
```
+++

The terminal should output a linting error.
Loading

0 comments on commit 334088f

Please sign in to comment.