So ESLint’s defaults were to assume all files were ECMAScript 5. ECMAScript 6 was on the horizon but no one knew how quickly it would be implemented or how modules (ESM) would end up being used. When ESLint was first created, ECMAScript 5 was the most recent version of JavaScript and most files were written as “shared everything” scripts or CommonJS modules (for Node.js). With these goals in mind, we came up with the new flat config system. While we knew 100% compatibility was probably unrealistic, we wanted to do our best to ensure existing shareable configs would work. In particular, we wanted to have ways for shareable configs to continue to work as closely as possible. Backwards compatibility should be a priority - even though we are moving to a new config system, we didn’t want to leave all of the existing ecosystem behind.It was important that these plugins continued to work. Existing plugins should work - the ESLint ecosystem is filled with hundreds of plugins. We need to look at which keys were necessary and how they related to one another. Better organized top-level keys - the number of keys at the top-level of eslintrc had grown dramatically since ESLint was released.Going forward, we wanted to leverage the loading capabilities of the JavaScript runtime directly. This was a significant source of complexity and, in hindsight, unnecessary. Use native loading for everything - one of our biggest regrets about eslintrc was recreating the Node.js require resolution in a custom way.The same rules key can be used the same way in flat config. Rules configs should remain unchanged - we felt like the way rules were configured already worked fine, so to make it easier to transition to flat config, we didn’t want to make any changes to rule configs.There should be one way to define configs for any given project. One way to define configs - we didn’t want folks to have multiple ways to do the same thing any longer.Logical defaults - the way people write JavaScript has changed a lot in the past nine years, and we wanted the new config system to reflect our current reality rather than the one we lived in when ESLint was first released.To set the stage for the changes in flat config, we had several goals: The result is something that hopefully feels familiar to existing ESLint users and is far more powerful than what was possible before.ĭocs: Read more about flat config system in the official documentation. We took all of the learnings from the previous six years of ESLint development to come up with a holistic approach to configuration that took the best of eslintrc and combined it with the way other JavaScript-related tools handled configuration. The flat config system, on the other hand, was designed from the start to be simpler in a number of ways. In my previous post, I talked about how the eslintrc config system had grown to be more complex than necessary through a series of small, incremental changes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |