@remix-run/eslint-config
This package includes a shareable ESLint config for Remix projects.
If you create your app with create-remix
no additional configuration is necessary.
Installation
First, install this package along with ESLint in your project. This package requires at least version 8.1 of ESLint
npm install -D eslint @remix-run/eslint-config
Then create a file named .eslintrc.js
in the root of your project:
module.exports = {
extends: "@remix-run/eslint-config",
};
Jest + Testing Library
This packages also ships with optional configuration options for projects that use Jest with Testing Library. To enable these rules, add the following to your .eslintrc
:
module.exports = {
extends: [
"@remix-run/eslint-config",
"@remix-run/eslint-config/jest-testing-library",
],
};
Please note that because this ruleset is optional, we do not include the core libraries as peer dependencies for this package. If you use these rules, be sure that you have the following dependencies installed in your project:
{
"dependencies": {
"@testing-library/jest-dom": ">=5.16.0",
"@testing-library/react": ">=12.0.0",
"jest": ">=28.0.0"
}
}
v2.9.0
Date: 2024-04-23
What's Changed
Single Fetch (unstable)
2.9.0
introduces a future.unstable_singleFetch
flag to enable to Single Fetch behavior (RFC) in your Remix application. Please refer to the docs for the full detail but the high-level changes to be aware of include:
- Naked objects returned from
loader
/action
functions are no longer automatically serialized to JSON responses
- Instead, they'll be streamed as-is via
turbo-stream
which allows direct serialization of more complex types such as Promise
, Date
, Map
instances, and more - You will need to modify your
tsconfig.json
's compilerOptions.types
array to infer types properly when using Single Fetch
- The
headers
export is no longer used when Single Fetch is enabled in favor of a new response
stub passed to your loader
/action
functions - The
json
/defer
/redirect
utilities are deprecated when using Single Fetch (but still work mostly the same) - Actions no longer automatically revalidate on
4xx
/5xx
responses - you can return a 2xx
to opt-into revalidation or use shouldRevalidate
[!IMPORTANT]
Single Fetch requires using undici
as your fetch polyfill, or using the built-in fetch on Node 20+, because it relies on APIs available there but not in the @remix-run/web-fetch
polyfill. Please refer to the Undici section below for more details.
- If you are managing your own server and calling
installGlobals()
, you will need to call installGlobals({ nativeFetch: true })
to avoid runtime errors when using Single Fetch - If you are using
remix-serve
, it will use undici
automatically if Single Fetch is enabled
Undici
Remix 2.9.0
adds a new installGlobals({ nativeFetch: true })
flag to opt into using undici
for the Web Fetch polyfills instead of the @remix-run/web-*
packages. This change has a few primary benefits:
- It will allow us to stop maintaining our own web-std-io fork in future versions of Remix
- It should bring us more in-line with spec compliance
- ⚠️ It is possible that some non-spec-compliant bugs in our fork will be "fixed" by moving to
undici
, so beware of "breaking bug fixes" and keep an eye on any advanced fetch
API interactions you're performing in your app - ⚠️ In some cases,
undici
may have different behavior by design -- most notably, undici
's garbage collection behavior differs and you are required to consume all fetch response bodies to avoid a memory leak in your app
- Because
undici
is the fetch implementation used by node
internally, it should better prepare Remix apps to more smoothly drop the polyfill to use the built-in Node.js APIs on node
20+
Minor Changes
- New
future.unstable_singleFetch
flag (#8773, #9073, #9084, #9272) @remix-run/node
- Add a new installGlobals({ nativeFetch: true })
flag to opt-into using undici
as the fetch polyfill instead of @remix-run/web-*
(#9106, #9111, #9198)@remix-run/server-runtime
- Add ResponseStub
header interface and deprecate the headers
export when Single Fetch is enabled (#9142)
Patch Changes
create-remix
- Allow .
in repo name when using --template
flag (#9026)@remix-run/dev
- Improve getDependenciesToBundle
resolution in monorepos (#8848)@remix-run/dev
- Fix SPA mode when Single Fetch is enabled by using streaming entry.server
(#9063)@remix-run/dev
- Vite: added sourcemap support for transformed routes (#8970)@remix-run/dev
- Update links printed to the console by the Remix CLI/Dev Server to point to updated docs locations (#9176)@remix-run/server-runtime
- Handle redirects created by handleDataRequest
(#9104)
Updated Dependencies
Changes by Package
Full Changelog: v2.8.1...v2.9.0