Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize eslint and prettier for the entire project with ci checks #109

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.github
.next
build
bundles
coverage
dist
lib
node_modules
out
public
28 changes: 14 additions & 14 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ extends:
- plugin:react-hooks/recommended
- plugin:jest/recommended
- plugin:jest-dom/recommended
parser: "@babel/eslint-parser"
parser: '@babel/eslint-parser'
plugins:
- "@babel"
- '@babel'
- jest
- react
- react-hooks
- testing-library
overrides:
- files:
- "**/__tests__/**/*.[jt]s?(x)"
- "**/?(*.)+(spec|test).[jt]s?(x)"
- '**/__tests__/**/*.[jt]s?(x)'
- '**/?(*.)+(spec|test).[jt]s?(x)'
extends:
- "plugin:testing-library/react"
- 'plugin:testing-library/react'
- files:
- "**/*.ts?(x)"
parser: "@typescript-eslint/parser"
- '**/*.ts?(x)'
parser: '@typescript-eslint/parser'
parserOptions:
tsconfigRootDir: .
project: ['./tsconfig.json']
tsconfigRootDir: .
project: ['./tsconfig.json']
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
rules:
"@typescript-eslint/no-unused-vars":
'@typescript-eslint/no-unused-vars':
- error
- varsIgnorePattern: "^_"
argsIgnorePattern: "^_"
- varsIgnorePattern: '^_'
argsIgnorePattern: '^_'
# For compat with jest: https://typescript-eslint.io/rules/unbound-method/
"@typescript-eslint/unbound-method": "off"
"jest/unbound-method": "error"
'@typescript-eslint/unbound-method': 'off'
'jest/unbound-method': 'error'
rules:
quotes:
- error
Expand Down
62 changes: 49 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,63 @@
name: rollbar-react CI
name: ci

on:
push:
branches: [ '**' ]
branches:
- main
pull_request:
branches: [ main ]
branches:
- main

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run test
- name: Checkout
uses: actions/checkout@v4

- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-
${{ runner.os }}-node-
${{ runner.os }}-

- name: Install dependencies
run: npm ci

- name: Install examples/create-react-app dependencies
run: npm ci
working-directory: ./examples/create-react-app

- name: Install examples/nextjs dependencies
run: npm ci
working-directory: ./examples/nextjs

- name: Install examples/typescript dependencies
run: npm ci
working-directory: ./examples/typescript

- name: Lint
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
prettier: true
eslint: true
eslint_extensions: js,jsx,ts,tsx
eslint_args: '--max-warnings 0'

- name: Test
run: npm run test
26 changes: 13 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
# Defaults to the user or organization that owns the workflow file
# scope: '@rollbar'
- run: npm install
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/checkout@v2
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v2
with:
node-version: "12.x"
registry-url: "https://registry.npmjs.org"
# Defaults to the user or organization that owns the workflow file
# scope: '@rollbar'
- run: npm install
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.github
.next
build
bundles
coverage
dist
lib
node_modules
out
public
38 changes: 38 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"[github-actions-workflow]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json5]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"files.trimTrailingWhitespace": true
}
Loading
Loading