Skip to content

🎥 Make videos programmatically with React

Docs: Document ESLint config and plugin packages

Igor Samokhovets2c09f815f491
diff --git a/packages/docs/docs/brownfield-installation.mdx b/packages/docs/docs/brownfield-installation.mdx
index 37cc457c92..3be5e1c9e0 100644
--- a/packages/docs/docs/brownfield-installation.mdx
+++ b/packages/docs/docs/brownfield-installation.mdx
@@ -6,9 +6,6 @@ sidebar_label: Installation in existing project
crumb: 'Brownfield integration'
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
Remotion can be installed into existing projects, such as [Next.JS](https://nextjs.org/), [React Router](https://reactrouter.com/), [Vite](https://vitejs.dev/guide/) or [Create React App](https://create-react-app.dev/), as well as server-only projects that run on Node.JS. Get started by adding the following packages:
<Installation pkg="remotion @remotion/cli" />
@@ -112,56 +109,11 @@ npx remotion render remotion/index.ts MyComp out.mp4
Replace the entrypoint, composition name and output filename with the values that correspond to your usecase.
-## Install the ESLint Plugin
-
-Remotion has an ESLint plugin that warns about improper usage of Remotion APIs. To add it to your existing project, install it:
+## Set up ESLint
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i -D @remotion/eslint-plugin
-```
+Remotion provides ESLint rules that warn about incorrect or inefficient use of Remotion APIs.
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add -D @remotion/eslint-plugin
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i -D @remotion/eslint-plugin
-```
-
- </TabItem>
-</Tabs>
-
-This snippet will enable the recommended rules only for the Remotion files:
-
-```json title=".eslintrc"
-{
- "plugins": ["@remotion"],
- "overrides": [
- {
- "files": ["remotion/*.{ts,tsx}"],
- "extends": ["plugin:@remotion/recommended"]
- }
- ]
-}
-```
+Use [`@remotion/eslint-plugin`](/docs/eslint-plugin) with your existing ESLint configuration. To use Remotion's complete ESLint setup, see [`@remotion/eslint-config`](/docs/eslint-config).
## Embed a Remotion video into your React app
diff --git a/packages/docs/docs/eslint-config.mdx b/packages/docs/docs/eslint-config.mdx
new file mode 100644
index 0000000000..e77ea6d338
--- /dev/null
+++ b/packages/docs/docs/eslint-config.mdx
@@ -0,0 +1,65 @@
+---
+image: /generated/articles-docs-eslint-config.png
+title: '@remotion/eslint-config'
+sidebar_label: '@remotion/eslint-config'
+crumb: 'ESLint'
+---
+
+The Remotion ESLint configs provide recommended rules for JavaScript, TypeScript, React, React Hooks, and Remotion.
+
+Use a shared config when it can be the base ESLint configuration for your project. If your project already has an ESLint configuration, use [`@remotion/eslint-plugin`](/docs/eslint-plugin) directly instead.
+
+## Choose a config
+
+| ESLint version | Package | Config format |
+| --- | --- | --- |
+| 9 or later | `@remotion/eslint-config-flat` | Flat config |
+| 7.15 through 8.x with Remotion 4 | `@remotion/eslint-config` | Legacy config |
+| 8.57 or later with Remotion 5 | `@remotion/eslint-config` | Legacy config |
+
+## ESLint 9 and later
+
+Install the flat config:
+
+<Installation pkg="@remotion/eslint-config-flat" />
+
+Add an `eslint.config.mjs` file:
+
+```js title="eslint.config.mjs"
+import {config} from '@remotion/eslint-config-flat';
+
+export default config;
+```
+
+To apply Remotion-specific rules only to part of an existing project, use `makeConfig()`:
+
+```js title="eslint.config.mjs"
+import {makeConfig} from '@remotion/eslint-config-flat';
+
+export default makeConfig({
+ remotionDir: 'src/remotion/**/*.{ts,tsx}',
+});
+```
+
+The JavaScript, TypeScript, React, and React Hooks rules still apply to the whole project. Only the rules from [`@remotion/eslint-plugin`](/docs/eslint-plugin) are limited to `remotionDir`.
+
+## ESLint 8 and earlier
+
+Install the legacy config:
+
+<Installation pkg="@remotion/eslint-config" />
+
+Extend it from your ESLint configuration:
+
+```json title=".eslintrc"
+{
+ "extends": ["@remotion"]
+}
+```
+
+Remotion 4 supports ESLint 7.15 and later. Remotion 5 requires ESLint <MinEslintVersion /> or later. Use `@remotion/eslint-config-flat` when upgrading to ESLint 9.
+
+## See also
+
+- [`@remotion/eslint-plugin`](/docs/eslint-plugin)
+- [Installing Remotion in an existing project](/docs/brownfield)
diff --git a/packages/docs/docs/eslint-plugin.mdx b/packages/docs/docs/eslint-plugin.mdx
new file mode 100644
index 0000000000..003ebf058b
--- /dev/null
+++ b/packages/docs/docs/eslint-plugin.mdx
@@ -0,0 +1,52 @@
+---
+image: /generated/articles-docs-eslint-plugin.png
+title: '@remotion/eslint-plugin'
+sidebar_label: '@remotion/eslint-plugin'
+crumb: 'ESLint'
+---
+
+`@remotion/eslint-plugin` warns about incorrect or inefficient use of Remotion APIs.
+
+Use the plugin directly when your project already has an ESLint configuration, for example in a Next.js or React Router project. To use Remotion's complete ESLint setup, use an [`@remotion/eslint-config` package](/docs/eslint-config) instead.
+
+## Installation
+
+<Installation pkg="@remotion/eslint-plugin" />
+
+The plugin supports ESLint 7 and later, using either a legacy or flat configuration.
+
+## Flat config
+
+Import `flatPlugin` and add it to your existing configuration. This example enables the recommended rules only for Remotion files:
+
+```js title="eslint.config.mjs"
+import remotion from '@remotion/eslint-plugin';
+
+export default [
+ // Your existing ESLint configuration
+ {
+ files: ['src/remotion/**/*.{js,jsx,ts,tsx}'],
+ ...remotion.flatPlugin,
+ },
+];
+```
+
+## Legacy config
+
+Extend `plugin:@remotion/recommended` in an override to enable the recommended rules only for Remotion files:
+
+```json title=".eslintrc"
+{
+ "overrides": [
+ {
+ "files": ["src/remotion/**/*.{js,jsx,ts,tsx}"],
+ "extends": ["plugin:@remotion/recommended"]
+ }
+ ]
+}
+```
+
+## See also
+
+- [`@remotion/eslint-config`](/docs/eslint-config)
+- [Installing Remotion in an existing project](/docs/brownfield)
diff --git a/packages/docs/docs/getting-started.mdx b/packages/docs/docs/getting-started.mdx
index f7616c12f8..b495c026e2 100644
--- a/packages/docs/docs/getting-started.mdx
+++ b/packages/docs/docs/getting-started.mdx
@@ -139,6 +139,10 @@ npm run remotion
</TabItem>
</Tabs>
+## ESLint
+
+Remotion templates include a recommended ESLint configuration. See [`@remotion/eslint-config`](/docs/eslint-config) to choose the config for your ESLint version or to add it to another project.
+
## System requirements
To use Remotion, you need at least [Node](https://nodejs.org/en/download/) <MinNodeVersion /> or [Bun](https://bun.sh) <MinBunVersion />.
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 744fb83e52..7bb7b827b8 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -367,6 +367,8 @@ const sidebars: SidebarsConfig = {
},
items: ['enable-scss/enable-scss'],
},
+ 'eslint-config',
+ 'eslint-plugin',
{
type: 'category',
label: '@remotion/fonts',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index fb81c783b3..8afcd800ed 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -2609,6 +2609,24 @@ export const articles = [
noAi: false,
slug: 'env-variables',
},
+ {
+ id: 'eslint-config',
+ title: '@remotion/eslint-config',
+ relativePath: 'docs/eslint-config.mdx',
+ compId: 'articles-docs-eslint-config',
+ crumb: 'ESLint',
+ noAi: false,
+ slug: 'eslint-config',
+ },
+ {
+ id: 'eslint-plugin',
+ title: '@remotion/eslint-plugin',
+ relativePath: 'docs/eslint-plugin.mdx',
+ compId: 'articles-docs-eslint-plugin',
+ crumb: 'ESLint',
+ noAi: false,
+ slug: 'eslint-plugin',
+ },
{
id: 'export-opentimeline',
title: 'Export to OpenTimelineIO',
diff --git a/packages/docs/static/generated/articles-docs-eslint-config.png b/packages/docs/static/generated/articles-docs-eslint-config.png
new file mode 100644
index 0000000000..fe3cf53b2e
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-eslint-config.png differ
diff --git a/packages/docs/static/generated/articles-docs-eslint-plugin.png b/packages/docs/static/generated/articles-docs-eslint-plugin.png
new file mode 100644
index 0000000000..7225eab51f
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-eslint-plugin.png differ