This repository contains opinionated configurations for some tooling of the javascript ecosystem.
To use the minimal configuration, create or update the eslint.config.js
file in your project with the following content:
import { defineConfig } from '@ecohead/configs/eslint';
export default defineConfig({
// Your additional configuration here
});
The defineConfig
function also accepts as a second argument an array of files to be ignored by eslint in your project.
I provide some built-in configurations that you can use directly in your project, based on my personal preferences. I have disabled some rules that I find too strict or not useful for my use case. You are free to use them all or only some of them.
If you want to include all of them, I export a special variable that contains all the configurations.
import { defineConfig, all } from '@ecohead/configs/eslint';
export default defineConfig([...all]);
import { defineConfig, native } from '@ecohead/configs/eslint';
export default defineConfig([...native]);
import { defineConfig, typescript } from '@ecohead/configs/eslint';
export default defineConfig([...typescript]);
import { defineConfig, unicorn } from '@ecohead/configs/eslint';
export default defineConfig([...unicorn]);
import { defineConfig, sonar } from '@ecohead/configs/eslint';
export default defineConfig([...sonar]);
import { defineConfig, comments } from '@ecohead/configs/eslint';
export default defineConfig([...comments]);
import { defineConfig, node } from '@ecohead/configs/eslint';
export default defineConfig([...node]);
import { defineConfig, prettier } from '@ecohead/configs/eslint';
export default defineConfig([...prettier]);
import { defineConfig, noUseExtendNative } from '@ecohead/configs/eslint';
export default defineConfig([...noUseExtendNative]);
import { defineConfig, promise } from '@ecohead/configs/eslint';
export default defineConfig([...promise]);
import { defineConfig, importX } from '@ecohead/configs/eslint';
export default defineConfig([...importX]);
import { defineConfig, tailwindcss } from '@ecohead/configs/eslint';
export default defineConfig([...tailwindcss]);
import { defineConfig, adonis } from '@ecohead/configs/eslint';
export default defineConfig([...adonis]);
import { defineConfig, unocss } from '@ecohead/configs/eslint';
export default defineConfig([...unocss]);
The configuration is based mainly for accessibility and readability purposes, which for some part is inherited from this reddit post.
To use the configuration, you can add the following to your prettier.config.js
file:
import { definePrettierConfig } from '@ecohead/configs/prettier';
export default definePrettierConfig({
// Your additional configuration here
});
This plugin formats the package.json
file in a more readable way, using sort-package-json
under the hood.
To add a plugin in your configuration, simply add it to the plugins
array in the definedPrettierConfig
function
after installing it.
The following example shows how to add the prettier-plugin-tailwindcss
plugin:
import { definePrettierConfig } from '@ecohead/configs/prettier';
export default definePrettierConfig({
// Your additional configuration here
plugins: [
// ...
'prettier-plugin-tailwindcss',
],
tailwindFunctions: ['clsx', 'cx', 'cva', 'cw', 'twMerge', 'tw'],
});
I export two configurations :
- One for CSS files
- One for SCSS files
The SCSS configuration is based on the CSS configuration, with some additional rules for SCSS files.
To use the configuration, you can add the following to your stylelint.config.js
file:
import { css, scss } from '@ecohead/configs/stylelint';
/** @type {import('stylelint').Config} */
export default {
...css, // or ...scss
// Your additional configuration here
};
The TypeScript configuration is as strict as possible from my point of view. It is inherited in high parts from the astro team's configuration.
I also export a special tsconfig file dedicated to eslint, which enables the noEmit
flag.
To use the configuration, you can add the following to your tsconfig.json
file:
For the default configuration:
{
"extends": "@ecohead/configs/tsconfig.json",
"compilerOptions": {
// Your additional configuration here
}
}
For the eslint configuration:
{
"extends": "@ecohead/configs/tsconfig.eslint.json",
"compilerOptions": {
// Your additional configuration here
}
}