Skip to content

Commit

Permalink
feat: enable enforce-node-prefix by default (#73)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop Node.js < 18.19.0 support

new features:

 - support es2022 by default
 - enable enforce-node-prefix by default

other breaking changes:

 - remove react rules
 - remove babel
 - drop TypeScript < 5 support
  • Loading branch information
fengmk2 authored Jun 29, 2024
1 parent 26fc757 commit a6802b0
Show file tree
Hide file tree
Showing 41 changed files with 122 additions and 694 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

Expand All @@ -13,4 +12,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
version: '16, 18, 20'
version: '18.19.0, 18, 20, 22'
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ jobs:
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
99 changes: 8 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[download-image]: https://img.shields.io/npm/dm/eslint-config-egg.svg?style=flat-square
[download-url]: https://npmjs.org/package/eslint-config-egg

Node.js Style Guide for Eggjs and Node.js
Node.js Style Guide for EggJS

## Install

Expand All @@ -34,7 +34,7 @@ npm i eslint eslint-config-egg --save-dev
```json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint-config-egg": "14",
"eslint": "8"
}
}
Expand All @@ -45,8 +45,7 @@ npm i eslint eslint-config-egg --save-dev
```json
{
"extends": [
"eslint-config-egg",
"eslint-config-egg/lib/rules/enforce-node-prefix"
"eslint-config-egg"
]
}
```
Expand All @@ -59,7 +58,7 @@ npm i eslint eslint-config-egg --save-dev
{
"devDependencies": {
"eslint-config-egg": "13",
"typescript": "^4.5.2"
"typescript": "5"
}
}
```
Expand All @@ -69,8 +68,7 @@ npm i eslint eslint-config-egg --save-dev
```json
{
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
"eslint-config-egg/typescript"
]
}
```
Expand All @@ -93,98 +91,17 @@ npm i eslint eslint-config-egg --save-dev
{
"language": "typescript",
"autoFix": true
},
}
]
}
```

### Use with Experimental Features

If you want to use eslint-config-egg with experimental features such as `async function`, you should use `@babel/eslint-parser` parser:

- `package.json`

```json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7"
}
}
```

- `.eslintrc.js`

```js
module.exports = {
extends: 'eslint-config-egg',
// for experimental features support
parser: '@babel/eslint-parser',
rules: {
// see https://github.com/eslint/eslint/issues/6274
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
}
};
```

### Use with React in Front-End

If you want to use eslint-config-egg with react, jsx and es6 modules:

- `package.json`

```json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7",
"eslint-plugin-react": "7"
}
}
```

- `.eslintrc.js`

```js
module.exports = {
extends: 'eslint-config-egg',
// for experimental features support
parser: '@babel/eslint-parser',
parserOptions: {
// for es6 module
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
// for variables in jsx
'react/jsx-uses-vars': 'error',
// see https://github.com/eslint/eslint/issues/6274
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
},
};
```

## License

[MIT](LICENSE)

<!-- GITCONTRIBUTOR_START -->

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src="https://avatars.githubusercontent.com/u/3580607?v=4" width="100px;"/><br/><sub><b>benjycui</b></sub>](https://github.com/benjycui)<br/>|[<img src="https://avatars.githubusercontent.com/u/3274850?v=4" width="100px;"/><br/><sub><b>geekdada</b></sub>](https://github.com/geekdada)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/2039144?v=4" width="100px;"/><br/><sub><b>sang4lv</b></sub>](https://github.com/sang4lv)<br/>|[<img src="https://avatars.githubusercontent.com/u/2972143?v=4" width="100px;"/><br/><sub><b>nightink</b></sub>](https://github.com/nightink)<br/>|[<img src="https://avatars.githubusercontent.com/u/2724034?v=4" width="100px;"/><br/><sub><b>missjing</b></sub>](https://github.com/missjing)<br/>|[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>|[<img src="https://avatars.githubusercontent.com/u/15117664?v=4" width="100px;"/><br/><sub><b>zhaoxingyue</b></sub>](https://github.com/zhaoxingyue)<br/>|
[<img src="https://avatars.githubusercontent.com/u/10082151?v=4" width="100px;"/><br/><sub><b>bowei-jbw</b></sub>](https://github.com/bowei-jbw)<br/>|[<img src="https://avatars.githubusercontent.com/u/13050025?v=4" width="100px;"/><br/><sub><b>aladdin-add</b></sub>](https://github.com/aladdin-add)<br/>|[<img src="https://avatars.githubusercontent.com/u/143572?v=4" width="100px;"/><br/><sub><b>hotoo</b></sub>](https://github.com/hotoo)<br/>

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Jun 02 2022 15:10:46 GMT+0800`.
[![Contributors](https://contrib.rocks/image?repo=eggjs/eslint-config-egg)](https://github.com/eggjs/eslint-config-egg/graphs/contributors)

<!-- GITCONTRIBUTOR_END -->
Made with [contributors-img](https://contrib.rocks).
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const builtin = [
'./lib/legacy',
'./lib/rules/enforce-node-prefix',
'./lib/rules/es6',
'./lib/rules/es2020',
'./lib/rules/es2022',
].map(require.resolve);

module.exports = {
extends: builtin.concat([
'plugin:eggache/recommended',
]),
parserOptions: {
ecmaVersion: 2020,
ecmaVersion: 2022,
sourceType: 'script',
},
};
2 changes: 1 addition & 1 deletion lib/rules/es2020.js → lib/rules/es2022.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
env: {
es2020: true,
es2022: true,
},
};
108 changes: 0 additions & 108 deletions lib/rules/react-a11y.js

This file was deleted.

Loading

0 comments on commit a6802b0

Please sign in to comment.