ESLint One for All Made Easy

Rate this content
Bookmark
ESLint Flat Config is a new feature in version 9.0 that simplifies configurations using native ES module imports. The video explains the differences between the legacy ESLint RSA config and the new Flat Config, highlighting the ease of renaming or switching plugins without changing array rules. The ESLint config inspect tool visualizes the final resolved config, aiding in understanding each config item. The ESLint Flat Config utilities library provides a compose function for resolving different types of configurations. The video also touches on using ESLint as a formatter and its flexibility compared to Prettier. Various plugins support ESLint for different languages, including TypeScript, Vue, and JSON. The speaker also discusses using ESLint for code modifications with the ESLint-plugin-command and how meta frameworks like Nuxt benefit from project-aware configurations.

From Author:

Introduce to the new ESLint flat config format, and see how it can greatly improve our experience for both rule makers and users. Make the black box transparent, and easy to understand.

This talk has been presented at JSNation 2024, check out the latest edition of this JavaScript Conference.

FAQ

Anthony Fu is a co-member of Vite, Vue, and Nuxt, and the creator of several projects including Vite's LightDev, Uno CSS Type Challenges, and Elk. He is also the maintainer of ESLink, StylistLink, and Cheeky2slash, and currently works at Nuzlab on the framework team.

SlideF is a markdown-based presentation tool built on top of web technologies. It allows users to create presentations using markdown files and provides features like embedding interactive components and applications.

ESLint Flat Config is a new configuration system introduced in ESLint version 9.0. It simplifies configuration by using native ES module imports and allows for more explicit and flexible setups.

To migrate to ESLint Flat Config, you can use the CLI tool `ESLint/migration-config` which automatically converts your legacy code to a Flat Config. Additionally, you can refer to the ESLint documentation for a detailed migration guide.

Some tools and plugins that support ESLint Flat Config include `ESLint-config-inspect` for visualizing and inspecting your final resolved config, and `ESLint-flat-config-utilities` for composing and managing different types of configurations.

Yes, ESLint can be configured to lint other languages such as TypeScript, Vue components, Svelte components, Astro, JSON, YAML, and more. There are various plugins available to support these languages.

The ESLint Stylistic project gathers all stylistic rules for JavaScript, TypeScript, and JSX into one organization. This project helps maintain these rules and allows users to use ESLint as a formatter.

Yes, ESLint can be used as a code mod tool. For example, the `ESLint-plugin-command` allows for on-demand micro code modifications using magic comments.

ESLint Flat Config allows meta frameworks like Nuxt to provide project-aware configurations. This means that different files and directories can have specific linting rules applied automatically, based on the project's setup.

You can inspect your ESLint Flat Config by using the `ESLint --inspect-config` command in your CLI. This opens a browser page with a visual interface where you can see all config items and how they contribute to the final configuration.

Anthony Fu
Anthony Fu
27 min
13 Jun, 2024

Comments

Sign in or register to post your comment.
  • Stanisław Gregor
    Stanisław Gregor
    IDEALIGN Stanisław Gregor
    Thank you, Anthony, for this presentation. My only regret is that it was so short and that you had to hurry. I hope I'll be able to see and hear you live sometime! Thank you once more <3
  • Kevin Cocquyt
    Kevin Cocquyt
    Great talk and thanks for the information. Within my team, devs (and myself) find it confusing to know when ESLint or Prettier is doing all the work. I'll try and test if Stylistic would do the necessary work for me (instead of Prettier) and might propose it to the team afterwards.

Video Transcription

Available in Español: ESLint Uno para Todos Hecho Fácil

1. Introduction to ESLink and Flat Config

Short description:

Hello, everyone! Thank you for being here. I'm Anthony Fu, a co-member of Vite, Vue, and Knox. I'm excited to share my findings and practices with ESLink. ESLink is a popular and constantly improving tool. Today, I'll talk about ESLinks One for All Made Easy and the new features in version 9.0, like Flat Config. If you haven't heard about it, I'll explain why you should consider using it.

Alright. How's everybody doing? Okay. Hello, everyone, and thank you so much for being here and I didn't expect we have so many of you here, so thank you.

I'm so glad to be here at JS Nation.

So, first let me introduce myself a little bit. Okay, it worked. Okay. And yeah, my name is Anthony Fu, and I'm a co-member of Vite, Vue, and Knox, and also the creator of Vite's LightDev, Uno CSS Type Challenges, and Elk. I'm also the maintainer of ESLink, StylistLink, and Cheeky2slash. I'm currently working at Nuzlab on the framework team and you can find me on the links, with the links below.

So, as you can see that I'm pretty enthusiastic about open source and driven me into working in many projects. So, I love building tools and figuring out the problems I encounter. Like, for example, like the slide you are looking at is powered by SlideF, a markdown-based presentation tool that's built on top of web technologies. It's born when I find that existing tools was not flexible enough for me to present my code. So, similarly, when I look into ESLink and its ecosystem a few months ago, I find that many things are very interesting but it's not yet fully explored. So, today I'd like to share with you some of my findings and practice during my recent explorations around it. And actually, this is, like, a 30-minute talk but I find that I only have 20 minutes, so I need to rush it and hope you don't mind.

11 years since ESLink comes out, at this moment, it's easily one of the most popular tools that's basically every project we use. And despite its being around for such a long time, it's a tool that's still consistently improving and evolving. And today, I'd like to give a board ambitious topic like ESLinks One for All Made Easy, and to share with you some of the new perspective and the patterns of using ESLink with the latest features they just rolled out.

So, you probably have heard, like, ESLink version 9.0 just released roughly two months ago, and the main highlight is the major version is rolling out the new configuration system called Flat Config. So, before we start, I'd like to do a quick survey here, like, have you ever heard about, like, ESLink Flat Config? Could you please raise your hand for me? Okay. That's a lot. Okay. And how many of you are already using or migrate to ESLink? Okay. That's a few, like, 20-something? Okay. Good. Okay. Thank you. And so, for those who haven't on Flat Config yet, so, today, I'm here to tell you why you should.

2. Comparison of Legacy ESLink Config and Flat Config

Short description:

Let's compare the legacy ESLink RSA config with the new Flat Config. The legacy config uses .ESLinkRC and convention-based extents, while the Flat Config uses ESLink.config.ts and native imports. With the Flat Config, you can easily rename or switch plugins without changing array rules. It simplifies the complex tree structure of shared configs and has been in the works for five years. ESLinux has put in a lot of effort, publishing blog posts and sharing the roadmap. The biggest benefit of Flat Config is the full control and simplicity it offers in JavaScript with native imports.

So, in case you have never heard about it and here, let me do a quick comparison between the legacy ESLink RSA config and the new Flat Config for you. And to differentiate between those two configuration formats is rather straightforward, and the legacy config is named with .ESLinkRC that supports various extensions such you could have, like, .js, .jsum, or sometimes you can also read the config from your package.jsum. And in the Flat Config, on the other hand, it's only loaded from ESLink.config.ts, a JavaScript config file that's as the single source of choose.

And when it comes to reusing the shared config, the legacy config format implicitly uses a convention-based extents to load the config from your local node modules. And, by the way, this was like created before, like, we have ESL modules or something. So, you would need to learn a little bit about, like, how this convention work and to know how it's resolved and how it's mapping to the package you have. Well, the Flat Config will use native ESL import where it's more explicit and it also gives you more control. And for plugins, it takes an array of strings. It used to take an array of strings, which again is also convention-based and coupled with the plugin's package name. And now, in the Flat Config, it takes a name object for plugins. And this means you can now rename this plugin easily or switch to a fork without being forced to change array rules in your config.

So, also, the inherent nature of extents might result in very complex tree structure because the shared config can also have nettings in extent inside. So, in the Flat Config, it gets simplified a lot, where you explicitly import a shared config as multiple objects or arrays and you can compose them into a single flat array. So, that's why it's called Flat Config. So, to give a little bit more context, here's a graph I draw to demonstrating the timeline. While the Flat Config might sound new to some of you, it actually has been planned for five years already. The RFC was created in January 2019 and the first implementation is available in version 8.21 as experimental, which is two years ago, and become stable in 8.45 and now it becomes default recently in V9. And in between, ESLinux has pushed a lot. It's also like a published multiple blog post to explain the reason why they want to introduce the new format and share the roadmap of rolling out plan. And that's a lot of effort spent across these five years' plan. So, huge respect to the ESLinux team. And as we mentioned in a previous slide, the biggest benefit of Flat Config now is in JavaScript where you have full control and also use native imports to resolve the plugins and the configs, making the inheritance and overriding a lot simpler.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Routing in React 18 and Beyond
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Routing in React 18 brings a native app-like user experience and allows applications to transition between different environments. React Router and Next.js have different approaches to routing, with React Router using component-based routing and Next.js using file system-based routing. React server components provide the primitives to address the disadvantages of multipage applications while maintaining the same user experience. Improving navigation and routing in React involves including loading UI, pre-rendering parts of the screen, and using server components for more performant experiences. Next.js and Remix are moving towards a converging solution by combining component-based routing with file system routing.
Full-stack & typesafe React (+Native) apps with tRPC.io
React Advanced Conference 2021React Advanced Conference 2021
6 min
Full-stack & typesafe React (+Native) apps with tRPC.io
Top Content
Alex introduces tRPC, a toolkit for making end-to-end type-safe APIs easily, with auto-completion of API endpoints and inferred data from backend to frontend. tRPC works the same way in React Native and can be adopted incrementally. The example showcases backend communication with a database using queries and validators, with types inferred to the frontend and data retrieval done using Prisma ORM.
Thinking in React Query
React Summit 2023React Summit 2023
22 min
Thinking in React Query
Top Content
Watch video: Thinking in React Query
React Query is not a data fetching library, but an Asian state manager. It helps keep data up to date and manage agent life cycles efficiently. React Query provides fine-grained subscriptions and allows for adjusting stale time to control data fetching behavior. Defining stale time and managing dependencies are important aspects of working with React Query. Using the URL as a state manager and Zustand for managing filters in React Query can be powerful.
React Slots: a New Way of Composition
React Advanced Conference 2022React Advanced Conference 2022
21 min
React Slots: a New Way of Composition
Top Content
Today's Talk introduces React Snots, a new way of composition for design systems. The configuration way provides flexibility but can lead to uncontrolled use cases and wrong patterns. React Slots RFC was created to address the limitations of React's support for web components and slots. It introduces createHost and createSlot APIs to enable component composition and solve previous problems. React Slots RFC allows for flexible component styling and the creation of complex structures without rendering them to the browser.
Advanced Patterns for API Management in Large-Scale React Applications
React Advanced Conference 2021React Advanced Conference 2021
20 min
Advanced Patterns for API Management in Large-Scale React Applications
Top Content
This Talk covers advanced patterns for API management in large-scale React applications. It introduces the concept of an API layer to manage API requests in a more organized and maintainable way. The benefits of using an API layer include improved maintainability, scalability, flexibility, and code reusability. The Talk also explores how to handle API states and statuses in React, and provides examples of canceling requests with Axios and React Query. Additionally, it explains how to use the API layer with React Query for simplified API management.
7 TypeScript Patterns You Should Be Using
React Summit 2023React Summit 2023
19 min
7 TypeScript Patterns You Should Be Using
Top Content
Watch video: 7 TypeScript Patterns You Should Be Using
This Talk introduces 7 essential TypeScript patterns for React development, including children, spreading props, either-or, generic components, and context. The speaker demonstrates various implementations and provides examples using a fictional dog grooming salon application. Other interesting ideas include using omit and make required types, creating components with either-or interfaces, and using generics, memorization, and context in React. The speaker also introduces the Recontextual library for context management.

Workshops on related topic

Master JavaScript Patterns
JSNation 2024JSNation 2024
145 min
Master JavaScript Patterns
Featured Workshop
Adrian Hajdin
Adrian Hajdin
During this workshop, participants will review the essential JavaScript patterns that every developer should know. Through hands-on exercises, real-world examples, and interactive discussions, attendees will deepen their understanding of best practices for organizing code, solving common challenges, and designing scalable architectures. By the end of the workshop, participants will gain newfound confidence in their ability to write high-quality JavaScript code that stands the test of time.
Points Covered:
1. Introduction to JavaScript Patterns2. Foundational Patterns3. Object Creation Patterns4. Behavioral Patterns5. Architectural Patterns6. Hands-On Exercises and Case Studies
How It Will Help Developers:
- Gain a deep understanding of JavaScript patterns and their applications in real-world scenarios- Learn best practices for organizing code, solving common challenges, and designing scalable architectures- Enhance problem-solving skills and code readability- Improve collaboration and communication within development teams- Accelerate career growth and opportunities for advancement in the software industry
Best Practices and Patterns for Managing API Requests and States
React Advanced Conference 2022React Advanced Conference 2022
206 min
Best Practices and Patterns for Managing API Requests and States
Workshop
Thomas Findlay
Thomas Findlay
With the rise of frameworks, such as React, Vue or Angular, the way websites are built changed over the years. Modern applications can be very dynamic and perform multiple API requests to populate a website with fresh content or submit new data to a server. However, this paradigm shift introduced new problems developers need to deal with. When an API request is pending, succeeds, or fails, a user should be presented with meaningful feedback. Other problems can comprise API data caching or syncing the client state with the server. All of these problems require solutions that need to be coded, but these can quickly get out of hand and result in a codebase that is hard to extend and maintain. In this workshop, we will cover how to handle API requests, API states and request cancellation by implementing an API Layer and combining it with React-Query.
Prerequisites: To make the most out of this workshop, you should be familiar with React and Hooks, such as useState, useEffect, etc. If you would like to code along, make sure you have Git, a code editor, Node, and npm installed on your machine.