Editor Setup - Flowbite React
Learn how to setup intellisense, format and lint support for Flowbite React
To bring intellisense, format and lint support for the custom theme
prop, we need to create the following IDE configuration files.
#
Visual Studio Code#
Intellisense- Install the official Tailwind CSS IntelliSense extension for Visual Studio Code.
- Create
.vscode
directory at the root level of the application:
mkdir .vscode
- Create
settings.json
file in the.vscode
directory:
touch .vscode/settings.json
- Add the following content to
settings.json
:
{
"tailwindCSS.classAttributes": ["class", "className", "theme"],
"tailwindCSS.experimental.classRegex": [
["twMerge\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["createTheme\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
#
Format (Prettier)- Install
prettier
andprettier-plugin-tailwindcss
packages:
npm i -D prettier prettier-plugin-tailwindcss
- Create a
prettier
configuration file namedprettier.config.js
:
touch prettier.config.js
- Add
prettier-plugin-tailwindcss
toplugins
list and configure target tailwind attributes and functions:
/** @type {import('prettier').Config} */
module.exports = {
plugins: ["prettier-plugin-tailwindcss"],
// tailwindcss
tailwindAttributes: ["theme"],
tailwindFunctions: ["twMerge", "createTheme"],
};
#
Lint (ESlint)- Install and configure
eslint
npm init @eslint/config
- Install
eslint-plugin-tailwindcss
package:
npm i -D eslint-plugin-tailwindcss
- Add
plugin:tailwindcss/recommended
toextends
and configuresettings.tailwindcss
:
/** @type {import("eslint").Linter.Config} */
module.exports = {
// ...
extends: [
// ...
"plugin:tailwindcss/recommended",
],
settings: {
// ...
tailwindcss: {
callees: ["twMerge", "createTheme"],
classRegex: "^(class(Name)|theme)?$",
},
},
};