Skip to content

Commit 2867bb2

Browse files
authored
remotion: Raise v5 Node and ESLint requirements (#9533)
* `remotion`: Raise v5 Node and ESLint requirements * Docs: Remove ESLint requirement from getting started
1 parent 0a00997 commit 2867bb2

5 files changed

Lines changed: 52 additions & 3 deletions

File tree

packages/core/src/no-react.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ export const NoReactInternals = {
6666
getOffthreadVideoSource,
6767
getExpectedMediaFrameUncorrected,
6868
ENABLE_V5_BREAKING_CHANGES,
69-
MIN_NODE_VERSION: ENABLE_V5_BREAKING_CHANGES ? 18 : 16,
69+
MIN_NODE_VERSION: ENABLE_V5_BREAKING_CHANGES ? 22 : 16,
7070
MIN_BUN_VERSION: ENABLE_V5_BREAKING_CHANGES ? '1.1.3' : '1.0.3',
71+
MIN_ESLINT_VERSION: ENABLE_V5_BREAKING_CHANGES ? '8.57.0' : '7.15.0',
7172
colorNames,
7273
DATE_TOKEN,
7374
FILE_TOKEN,

packages/docs/docs/5-0-migration.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Run `npm i `, `yarn`, `pnpm i` or `bun i` respectively afterwards.
3333

3434
## Runtime requirements
3535

36-
The minimum Node version is now 18.0.0. The minimum Bun version is 1.1.3.
36+
The minimum Node version is now <MinNodeVersion />. The minimum Bun version is <MinBunVersion />.
37+
38+
If you use `@remotion/eslint-config`, the minimum ESLint version is now <MinEslintVersion />.
3739

3840
## `selectComposition()` and `getCompositions()` now require `inputProps`
3941

packages/docs/src/components/AvailableFrom.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ export const MinNodeVersion: React.FC = () => {
5151
export const MinBunVersion: React.FC = () => {
5252
return <span>{NoReactInternals.MIN_BUN_VERSION}</span>;
5353
};
54+
55+
export const MinEslintVersion: React.FC = () => {
56+
return <span>{NoReactInternals.MIN_ESLINT_VERSION}</span>;
57+
};

packages/docs/src/theme/MDXComponents.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {YouTube} from '../../components/YouTube';
1010
import {
1111
AvailableFrom,
1212
MinBunVersion,
13+
MinEslintVersion,
1314
MinNodeVersion,
1415
} from '../components/AvailableFrom';
1516
import {CompatibilityTable} from '../components/CompatibilityTable';
@@ -30,6 +31,7 @@ export default {
3031
TsType,
3132
MinNodeVersion,
3233
MinBunVersion,
34+
MinEslintVersion,
3335
Options,
3436
Credits,
3537
YouTube,

packages/eslint-config/src/patch-eslint.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@
1212
import fs from 'fs';
1313
import path from 'path';
1414

15+
const getMinEslintVersion = () => {
16+
const packageJson = JSON.parse(
17+
fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'),
18+
) as {version: string};
19+
const isV5Package = Number(packageJson.version.split('.')[0]) >= 5;
20+
21+
try {
22+
const {NoReactInternals} = require('remotion/no-react') as {
23+
NoReactInternals: {
24+
ENABLE_V5_BREAKING_CHANGES: boolean;
25+
MIN_ESLINT_VERSION: string;
26+
};
27+
};
28+
if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
29+
return NoReactInternals.MIN_ESLINT_VERSION;
30+
}
31+
} catch {
32+
// @remotion/eslint-config can be installed without remotion.
33+
}
34+
35+
return isV5Package ? '8.57.0' : null;
36+
};
37+
1538
export const allowESLintShareableConfig = () => {
1639
const isModuleResolutionError: (ex: unknown) => boolean = (ex) =>
1740
typeof ex === 'object' &&
@@ -228,12 +251,29 @@ export const allowESLintShareableConfig = () => {
228251
.toString();
229252
const eslintPackageObject = JSON.parse(eslintPackageJson);
230253
const eslintPackageVersion = eslintPackageObject.version;
231-
const versionMatch = /^([0-9]+)\./.exec(eslintPackageVersion); // parse the SemVer MAJOR part
254+
const versionMatch = /^([0-9]+)\.([0-9]+)\./.exec(eslintPackageVersion);
232255
if (!versionMatch) {
233256
throw new Error('Unable to parse ESLint version: ' + eslintPackageVersion);
234257
}
235258

236259
const eslintMajorVersion = Number(versionMatch[1]);
260+
const eslintMinorVersion = Number(versionMatch[2]);
261+
const minEslintVersion = getMinEslintVersion();
262+
if (minEslintVersion !== null) {
263+
const minVersionMatch = /^([0-9]+)\.([0-9]+)\./.exec(minEslintVersion)!;
264+
const minMajorVersion = Number(minVersionMatch[1]);
265+
const minMinorVersion = Number(minVersionMatch[2]);
266+
if (
267+
eslintMajorVersion < minMajorVersion ||
268+
(eslintMajorVersion === minMajorVersion &&
269+
eslintMinorVersion < minMinorVersion)
270+
) {
271+
throw new Error(
272+
`Remotion 5 requires ESLint ${minEslintVersion} or later. You currently have ESLint ${eslintPackageVersion}.`,
273+
);
274+
}
275+
}
276+
237277
if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 9)) {
238278
throw new Error(
239279
'The patch-eslint.js script has only been tested with ESLint version 6.x, 7.x, and 8.x, and 9.x.' +

0 commit comments

Comments
 (0)