Create ESLint and Prettier Configs for a Design System

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the Build a Complete Company Design System course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Build a Complete Company Design System, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Build a Complete Company Design System

So let's continue with ESLint and pre-tier configurations. In case you are not familiar with ESLint, ESLint is a tool that helps us to enforce a consistent styling with our code and can also quickly be the point problems that we may miss. So this is a really valuable tool in large teams when they need to cooperate together and enforce a common styling and move on. So to start, let's jump back to our code editor, close the tabs and create a new file called ESLint.js. ESLint RC.js to be correct and copy and paste the code you will find in the text version of this course. So here what we are doing is basically extended the recommended rules of ESLint, also the recommended rules for React, for TypeScript, for using React hooks, for accessibility, and then for pre-tier. So it will work in transactions with pre-tier and will not break in some specific rules. So now that we have everything, we can also create a pre-tier RC file and paste a minimal configuration, like the following one, which basically says to have a line of column, maximum of 80 columns, or 80 columns, and then a single code approach in our code. And then to actually use them, we need to install in-slint and pre-tier and all the packages we defined to plug in. This is a really big command, but you can find it in the text version of this course. We have a mistake, those would be our lowercase. And it's done. We can remove everything and go to our packages, react, and then the index. And let's now validate that it is actually working, to validate that it works. We can take some rules, here we can see the no-count, which means this allows sign-in operation in conditional expressions, and it has an example. Let's use this example and see if it will break or not. So in our case, we have this example, we have an issue with pre-tier, it cannot find module pre-tier. Maybe we need to restart our VS code. So we still have the problem, and the problem is that we are using the plug-and-play loader from yarn. So we can remove those files, go to the yarn RC, and paste the following line, which basically means instead of using plug-and-play from yarn, we will use node modules. We can go back to the terminal and just run a yarn to actually fit every single package. And hopefully if we restart the VS code now, it will work as expected. We can close this. We can close this. And here pre-tier is working, so if we format the file, it works. And we have also an issue with Islin as expected. As expected. That we cannot assign to a property of an object in an if condition, which is probably a mistake. But if we don't have Islin integrated to our IDE, we can also create a script to our root package, so we can check everything. So here we can create a script, let's call this lint, and paste the following command. So what we are doing here is that we are calling the Islin CLI, we ignore some paths, like the git ignore path. We want this to be quiet for warnings and do not match errors in some specific files. So we can run young lint. And we can see that we have an error and an error exit code here. So if we fix this part and remove this and run young lint again, everything passes the test. So that's how we installed pre-tier and Islin. Let's move to the next section of this course where we will talk about the foundation packets and how to deal with design tokens.