Skip to content

Commit

Permalink
Merge pull request #1 from VicSolWang/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VicSolWang committed Dec 23, 2021
2 parents fbc4d8e + dfc4fe5 commit 75007d1
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 93 deletions.
6 changes: 4 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ yarn.lock
.husky

# Coverage directory used by tools like istanbul
coverage
coverage*

# nyc test coverage
.nyc_output

# Github directory
.github

# Dependency directories
node_modules/

Expand All @@ -27,4 +30,3 @@ node_modules/

# macOS
.DS_Store

73 changes: 73 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# A workflow of VICSOLWANG's project

name: test-release-ci

on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master ]

jobs:
test:
strategy:
matrix:
node_version: ['12', '14', '16']
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- if: matrix.os == 'windows-latest'
run: git config --global core.autocrlf false
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
- uses: actions/cache@v2
id: cache-node_modules
with:
path: node_modules
key: ${{ matrix.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- run: node --version
- run: npm --version
- run: npm install
- run: npm test
- run: npm run cover:report
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.lcov

codecov:
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage
- uses: codecov/codecov-action@v2

release:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_name == 'master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install is-ci
- uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- if: steps.semantic.outputs.new_release_published == 'true'
run: echo ${{ steps.semantic.outputs.new_release_version }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yarn.lock
.husky

# Coverage directory used by tools like istanbul
coverage
coverage*

# nyc test coverage
.nyc_output
Expand Down
32 changes: 32 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Package lock
package-lock.json
yarn.lock

# Husky directory
.husky

# Coverage directory used by tools like istanbul
coverage*

# nyc test coverage
.nyc_output

# Github directory
.github

# Dependency directories
node_modules/

# IDE / Editor
.idea
.vscode

# macOS
.DS_Store
61 changes: 32 additions & 29 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Package lock
package-lock.json
yarn.lock

# Husky directory
.husky

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Dependency directories
node_modules/

# IDE / Editor
.idea
.vscode

# macOS
.DS_Store
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Package lock
package-lock.json
yarn.lock

# Husky directory
.husky

# Coverage directory used by tools like istanbul
coverage*

# nyc test coverage
.nyc_output

# Github directory
.github

# Dependency directories
node_modules/

# IDE / Editor
.idea
.vscode

# macOS
.DS_Store
21 changes: 21 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": ["docs/CHANGELOG.md", "package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# eslint-config-wzx-react

[![NPM version](https://img.shields.io/npm/v/eslint-config-wzx-react)](https://www.npmjs.com/package/eslint-config-wzx-react)
[![node](https://img.shields.io/node/v/eslint-config-wzx-react)](https://nodejs.org)
[![Build Status](https://travis-ci.com/VicSolWang/eslint-config-wzx-react.svg?branch=master)](https://travis-ci.com/VicSolWang/eslint-config-wzx-react)
[![codecov](https://codecov.io/gh/VicSolWang/eslint-config-wzx-react/branch/master/graph/badge.svg)](https://codecov.io/gh/VicSolWang/eslint-config-wzx-react)
[![NPM downloads](https://img.shields.io/npm/dt/eslint-config-wzx-react)](https://www.npmjs.com/package/eslint-config-wzx-react)
[![NPM version](https://img.shields.io/npm/v/eslint-config-wzx-react?logo=npm&style=flat-square)](https://www.npmjs.com/package/eslint-config-wzx-react)
[![node](https://img.shields.io/node/v/eslint-config-wzx-react?logo=nodedotjs&style=flat-square)](https://nodejs.org)
[![Code Style](https://img.shields.io/badge/code%20style-prettier-ff69b4?logo=prettier&style=flat-square)](https://prettier.io)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/VicSolWang/eslint-config-wzx-react/test-release-ci/master?logo=github&style=flat-square)](https://github.com/VicSolWang/eslint-config-wzx-react/actions/workflows/test-release.yml)
[![release](https://img.shields.io/badge/release-semantic--release-e10079?logo=semantic-release&style=flat-square)](https://github.com/semantic-release/semantic-release)
[![codecov](https://img.shields.io/codecov/c/gh/VicSolWang/eslint-config-wzx-react/master?label=codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/VicSolWang/eslint-config-wzx-react)
[![NPM downloads](https://img.shields.io/npm/dt/eslint-config-wzx-react?style=flat-square)](https://www.npmjs.com/package/eslint-config-wzx-react)

The custom react eslint rules based on [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb). (Support Typescript Eslint)
> The custom react eslint rules based on [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb). (Support Typescript Eslint)
# Installation
## :cd: Installation

npm install --save-dev eslint-config-wzx-react

Note: Typescript eslint needs to install [typescript](https://www.npmjs.com/package/typescript), [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser), [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin).
:bulb: Typescript eslint needs to install [typescript](https://www.npmjs.com/package/typescript), [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser), [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin).

npm install --save-dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin

# Usage
## :rocket: Usage

Add eslint-config-wzx-react to the "extends" in your `.eslintrc.* file`.

{
"extends": "wzx-react"
}

Note: Typescript eslint needs `tsconfig.json` in your project root directory.
:bulb: Typescript eslint needs `tsconfig.json` in your project root directory.

# License
## :lock: License

[MIT](LICENSE).
9 changes: 9 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Created by VICSOLWANG.
* Date: 2021/12/23 23:19
* Email: [email protected]
*/

export default {
files: ['test/test.js'],
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"cover:report": "nyc report --reporter=text-lcov > coverage.lcov",
"husky:pre-commit": "husky add .husky/pre-commit \"npx lint-staged\"",
"husky:commit-msg": "husky add .husky/commit-msg \"npx --no-install commitlint --edit $1\"",
"prepare": "husky install && npm run husky:pre-commit && npm run husky:commit-msg"
"husky:init": "husky install && npm run husky:pre-commit && npm run husky:commit-msg",
"prepare": "is-ci || npm run husky:init"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,7 +44,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0"
},
"peerDependencies": {
Expand All @@ -57,7 +58,9 @@
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"ava": "^3.15.0",
"fs-extra": "^10.0.0",
"husky": "^7.0.4",
"is-ci": "^3.0.1",
"lint-staged": "^12.1.3",
"nyc": "^15.1.0",
"prettier": "^2.5.1",
Expand Down
39 changes: 0 additions & 39 deletions test.js

This file was deleted.

28 changes: 28 additions & 0 deletions test/example/rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Created by VICSOLWANG.
* Date: 2021/12/23 23:24
* Email: [email protected]
*/

let a = 'eslint';

// 'global-require': 'warn'
if (a) {
require('eslint');
}

// 'import/no-dynamic-require': 'warn'
require(a);

// 'no-bitwise': 'off'
a = 1 & 2;

// 'no-nested-ternary': 'off'
a = a < 1 ? 0 : a < 2 ? 1 : 2;

// 'no-script-url': 'warn'
a = 'javascript:void(0)';

// 'no-underscore-dangle': 'off'
const _b = () => {};
_b();
8 changes: 8 additions & 0 deletions test/example/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Created by VICSOLWANG.
* Date: 2021/12/23 23:24
* Email: [email protected]
*/

const a = (): void => {};
a();
Loading

0 comments on commit 75007d1

Please sign in to comment.