Skip to content

Commit

Permalink
docs(readme): ajustes no readme
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefelipeschulle committed Jun 14, 2024
1 parent 13d2412 commit bfdbc2e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -50,4 +50,3 @@ jobs:

- name: Publish Packages on NPM
run: npm publish --provenance --access public

38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,66 +17,88 @@ 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

create file .eslintrc.json in main project folder, add the lines below in the file.

#### config node project

```json
{
"extends": "@brainylab/eslint-config/node"
}
```

#### config react project

```json
{
"extends": "@brainylab/eslint-config/react"
}
```

#### config react-native project

```json
{
"extends": "@brainylab/eslint-config/react-native"
}
```

#### config next project

```json
{
"extends": "@brainylab/eslint-config/next"
}
```

### Config VS Code to auto fix

create ou alter `.vscode/settings.json`.

```json
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.eslint": "explicit"
}
}
```
Expand Down
7 changes: 3 additions & 4 deletions src/create-config.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion src/presets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit bfdbc2e

Please sign in to comment.