From bfdbc2e2c3a412bbdda9deefa0cbfb80e388cf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Felipe=20Schulle?= Date: Fri, 14 Jun 2024 08:38:51 -0300 Subject: [PATCH] docs(readme): ajustes no readme --- .github/workflows/publish.yml | 5 ++--- README.md | 38 ++++++++++++++++++++++++++++------- src/create-config.ts | 7 +++---- src/presets/index.ts | 2 +- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ba49ee5..96bc4c3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: id-token: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: NodeJs Environment uses: actions/setup-node@v4 @@ -38,7 +38,7 @@ jobs: needs: [publish-grp] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: NodeJs Environment uses: actions/setup-node@v4 @@ -50,4 +50,3 @@ jobs: - name: Publish Packages on NPM run: npm publish --provenance --access public - diff --git a/README.md b/README.md index 51eaa7c..4aa9217 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ ## BrainyLab eslint-config + this is the base configuration of ESLint is used in the Projects made by BrainyLab Development. ## Install Config + ```bash # npm npm i --save-dev eslint prettier @brainylab/eslint-config @@ -15,25 +17,42 @@ pnpm add -D eslint prettier @brainylab/eslint-config ## Usage Flat Config - ESlint 9+ +Require Node.js >= 18.18, and ESLint >= 8.56.0. create file eslint.config.js or EMS eslint.config.mjs in main project folder, add the lines below in the file. +```js +import { createConfig } from '@brainylab/eslint-config'; +export default createConfig({ + configs: [ + /* your custom config */ + ], + presets: { + node: true, + typescript: true, + }, +}); +``` + +### Presets + ```javascript -import { configs } from '@brainylab/eslint-config/configs' +import { presets } from '@brainylab/eslint-config/configs'; export default [ [ /* your custom config */ ], // using base config - ...configs.base, + ...presets.base, // using typescript config - ...configs.typescript, + ...presets.typescript, // using typescript config - ...configs.node -] + ...presets.node, +]; ``` #### Config Prettier -para configurar o prettier corretamente, + +This library focuses on linter and prettier was separated for better performance, to use prettier together with ESlint, following this documentation [BrainyLab Prettier Config](https://www.npmjs.com/package/@brainylab/prettier-config) ## Usage Config Legacy @@ -41,6 +60,7 @@ para configurar o prettier corretamente, create file .eslintrc.json in main project folder, add the lines below in the file. #### config node project + ```json { "extends": "@brainylab/eslint-config/node" @@ -48,6 +68,7 @@ create file .eslintrc.json in main project folder, add the lines below in the fi ``` #### config react project + ```json { "extends": "@brainylab/eslint-config/react" @@ -55,6 +76,7 @@ create file .eslintrc.json in main project folder, add the lines below in the fi ``` #### config react-native project + ```json { "extends": "@brainylab/eslint-config/react-native" @@ -62,11 +84,13 @@ create file .eslintrc.json in main project folder, add the lines below in the fi ``` #### config next project + ```json { "extends": "@brainylab/eslint-config/next" } ``` + ### Config VS Code to auto fix create ou alter `.vscode/settings.json`. @@ -74,7 +98,7 @@ create ou alter `.vscode/settings.json`. ```json { "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit", + "source.fixAll.eslint": "explicit" } } ``` diff --git a/src/create-config.ts b/src/create-config.ts index bc38eeb..b2d557c 100644 --- a/src/create-config.ts +++ b/src/create-config.ts @@ -1,10 +1,10 @@ -import type { FlatESLintConfig } from 'eslint-define-config'; import { base } from './presets/base'; import { typescript } from './presets/typescript'; import { node } from './presets/node'; +import type { FlatESLintConfig } from 'eslint-define-config'; type ConfigParams = { - config: FlatESLintConfig | FlatESLintConfig[]; + config?: FlatESLintConfig | FlatESLintConfig[]; presets?: { typescript?: boolean; node?: boolean; @@ -22,12 +22,11 @@ export function createConfig(params: ConfigParams): FlatESLintConfig[] { configs.push(...node); } - if (Object.keys(params.config).length > 0) { + if (params.config) { configs.push( ...(Array.isArray(params.config) ? params.config : [params.config]), ); } return configs; - 899; } diff --git a/src/presets/index.ts b/src/presets/index.ts index c115049..a77b792 100644 --- a/src/presets/index.ts +++ b/src/presets/index.ts @@ -2,4 +2,4 @@ import { base } from './base'; import { typescript } from './typescript'; import { node } from './node'; -export const configs = { base, typescript, node }; +export const presets = { base, typescript, node };