mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
feat(eslint-plugin-react-hooks): merge rule from eslint-plugin-react-compiler into react-hooks plugin (#32416)
This change merges the `react-compiler` rule from `eslint-plugin-react-compiler` into the `eslint-plugin-react-hooks` plugin. In order to do the move in a way that keeps commit history with the moved files, but also no remove them from their origin until a future cleanup change can be done, I did the `git mv` first, and then recreated the files that were moved in their original places, as a separate commit. Unfortunately GH shows the moved files as new instead of the ones that are truly new. But in the IDE and `git blame`, commit history is intact with the moved files. Since this change adds new dependencies, and one of those dependencies has a higher `engines` declaration for `node` than what the plugin currently has, this is technically a breaking change and will have to go out as part of a major release. ### Related Changes - https://github.com/facebook/react/pull/32458 --------- Co-authored-by: Lauren Tan <poteto@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,8 @@ const Packaging = require('./packaging');
|
||||
const {asyncRimRaf} = require('./utils');
|
||||
const codeFrame = require('@babel/code-frame').default;
|
||||
const Wrappers = require('./wrappers');
|
||||
const commonjs = require('@rollup/plugin-commonjs');
|
||||
const {getBabelOutputPlugin} = require('@rollup/plugin-babel');
|
||||
|
||||
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
|
||||
|
||||
@@ -392,6 +394,7 @@ function getPlugins(
|
||||
};
|
||||
},
|
||||
},
|
||||
bundle.tsconfig != null ? commonjs() : false,
|
||||
// Shim any modules that need forking in this environment.
|
||||
useForks(forks),
|
||||
// Ensure we don't try to bundle any fbjs modules.
|
||||
@@ -415,13 +418,23 @@ function getPlugins(
|
||||
bundle
|
||||
)
|
||||
),
|
||||
// Remove 'use strict' from individual source files.
|
||||
{
|
||||
name: "remove 'use strict'",
|
||||
transform(source) {
|
||||
return source.replace(/['"]use strict["']/g, '');
|
||||
},
|
||||
},
|
||||
// For Meta internal requirements this package needs to be built targeting ES5.
|
||||
bundle.name === 'eslint-plugin-react-hooks'
|
||||
? getBabelOutputPlugin({
|
||||
presets: ['@babel/preset-env'],
|
||||
})
|
||||
: false,
|
||||
// Remove 'use strict' from individual source files. We skip eslint-plugin-react-hooks because
|
||||
// it bundles compiler-type code that may examine "use strict" used outside of a directive
|
||||
// context, e.g. as a StringLiteral.
|
||||
bundle.name !== 'eslint-plugin-react-hooks'
|
||||
? {
|
||||
name: "remove 'use strict'",
|
||||
transform(source) {
|
||||
return source.replace(/['"]use strict["']/g, '');
|
||||
},
|
||||
}
|
||||
: false,
|
||||
// Turn __DEV__ and process.env checks into constants.
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
@@ -490,7 +503,7 @@ function getPlugins(
|
||||
// takes care of it.
|
||||
renaming: false,
|
||||
}),
|
||||
needsMinifiedByClosure &&
|
||||
(needsMinifiedByClosure || bundle.name === 'eslint-plugin-react-hooks') &&
|
||||
// Add the whitespace back
|
||||
prettier({
|
||||
parser: 'flow',
|
||||
|
||||
Reference in New Issue
Block a user