Skip to content

Commit

Permalink
feat: rewrite with new flat ESLint config format (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed May 29, 2023
1 parent 34e6b2b commit 09ff00b
Show file tree
Hide file tree
Showing 39 changed files with 3,036 additions and 1,855 deletions.
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
node-version:
description: The version of node.js
required: false
default: '16'
default: '18'

runs:
using: composite
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
- name: Lint
run: nr lint

typecheck:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup

- name: Typecheck
run: nr typecheck
run: nr build
15 changes: 12 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ jobs:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
command: manifest
release-type: node
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}

publish:
runs-on: ubuntu-latest
needs: [version]
if: ${{ needs.version.outputs.release_created }}
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup

- name: Build
run: nr build

- name: Publish to NPM
run: pnpm -r publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 0 additions & 29 deletions .github/workflows/update-lock.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package-lock.json
yarn.lock
pnpm-lock.yaml

.next
.cache
.DS_Store
.idea
*.log
*.tgz
coverage
dist
lib-cov
logs
node_modules
temp
dist-types
*.tsbuildinfo
6 changes: 0 additions & 6 deletions .release-please-manifest.json

This file was deleted.

76 changes: 72 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,77 @@
# @ocavue/eslint-config

[![@ocavue/eslint-config](https://img.shields.io/npm/v/@ocavue/eslint-config/latest?label=%40ocavue%2Feslint-config)](https://www.npmjs.com/package/@ocavue/eslint-config)
[![@ocavue/eslint-config-react](https://img.shields.io/npm/v/@ocavue/eslint-config-react/latest?label=%40ocavue%2Feslint-config-react)](https://www.npmjs.com/package/@ocavue/eslint-config-react)
A set of ESLint shareable configs for TypeScript projects.

- Out of the box support for TypeScript, React, and Markdown
- Sort your imports
- Sort your fields in `package.json`

## License
## Install

MIT
```
$ npm install -D eslint prettier @ocavue/eslint-config
```

## Usage

### Config ESLint

You will need to use the new ["flat" ESLint configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new) (i.e. `eslint.config.js`).

In your `eslint.config.js` file, add the following to extend the basic config:

```JS
// eslint.config.js
import { basic } from '@ocavue/eslint-config'

export default [...basic()]
```

If you want to use the React config, you can do the following:

```JS
// eslint.config.js
import { basic, react } from '@ocavue/eslint-config'

export default [...basic(), ...react()]
```

If you want to use the check the code blocks in markdown files, you can do the following:

```JS
// eslint.config.js
import { basic, markdown } from '@ocavue/eslint-config'

export default [...basic(), ...markdown()]
```

### Add script for package.json

```json
{
"scripts": {
"lint": "eslint .",
"check": "prettier --check .",
"fix": "eslint --fix . && prettier --write ."
}
}
```

### Add `.prettierignore`

Add a [`.prettierignore`](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore) file in the root of your project. You can copy the `.prettierignore` file from this project.

### VS Code integration

If you are using VS Code, you and install [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode), then add the following to your VS Code settings:

```json
// .vscode/settings.json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
```
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineFlatConfig } from 'eslint-define-config'

import { basic } from './index.js'

export default defineFlatConfig(basic())
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './src/typescript.js'
export * from './src/prettier.js'
export * from './src/basic.js'
export * from './src/markdown.js'
export * from './src/react.js'
53 changes: 42 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "@ocavue/dev-config-monorepo",
"name": "@ocavue/eslint-config",
"type": "module",
"version": "0.0.0",
"private": true,
"packageManager": "pnpm@7.12.0",
"version": "0.5.0-beta.5",
"packageManager": "pnpm@8.5.1",
"description": "",
"author": "ocavue <ocavue@gmail.com>",
"license": "MIT",
Expand All @@ -16,16 +15,48 @@
"bugs": "https://github.com/ocavue/eslint-config/issues",
"keywords": [],
"sideEffects": false,
"main": "./index.js",
"module": "./index.js",
"types": "./dist/index.d.ts",
"files": [
"index.js",
"src",
"dist"
],
"scripts": {
"build": "tsc",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
"check": "prettier --check .",
"fix": "eslint --fix . && prettier --write .",
"prepublishOnly": "nr build"
},
"dependencies": {
"@types/eslint": "^8.40.0",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"eslint-config-prettier": "^8.8.0",
"eslint-define-config": "^1.20.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsonc": "^2.8.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^47.0.0",
"jsonc-eslint-parser": "^2.3.0"
},
"devDependencies": {
"@antfu/ni": "^0.18.8",
"@ocavue/eslint-config": "workspace:*",
"@types/node": "^18.11.18",
"eslint": "^8.31.0",
"prettier": "^2.8.2",
"typescript": "~4.9.4"
"@antfu/ni": "^0.21.3",
"@types/eslint-plugin-markdown": "^2.0.0",
"@types/node": "^18.16.15",
"eslint": "^8.41.0",
"prettier": "^2.8.8",
"typescript": "^5.0.4"
},
"renovate": {
"extends": [
"github>ocavue/config-renovate"
]
}
}
65 changes: 0 additions & 65 deletions packages/eslint-config-basic/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit 09ff00b

Please sign in to comment.