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 #110

Merged
merged 5 commits into from
Feb 26, 2024
Merged
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
58 changes: 44 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,57 @@
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]
node: [14, 16, 18, 20]

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 }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

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

- name: Install library dependencies
run: npm ci
- name: Install examples/create-react-app dependencies
run: cd examples/create-react-app && npm ci
- name: Install examples/nextjs dependencies
run: cd examples/nextjs && npm ci
- name: Install examples/typescript dependencies
run: cd examples/typescript && npm ci

- name: Lint
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
prettier: false
eslint: false
eslint_args: '--max-warnings 0'
matux marked this conversation as resolved.
Show resolved Hide resolved
eslint_extensions: js,jsx,ts,tsx

- 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: "14.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
}
1 change: 1 addition & 0 deletions examples/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"eject": "react-scripts eject"
},
"eslintConfig": {
"root": true,
"extends": [
"react-app",
"react-app/jest"
Expand Down
3 changes: 0 additions & 3 deletions examples/nextjs/.eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions examples/nextjs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
6 changes: 6 additions & 0 deletions examples/nextjs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: 'next/core-web-vitals',
ignorePatterns: ['node_modules'],
}
45 changes: 45 additions & 0 deletions examples/nextjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"rollbar": "^2.24.0"
},
"devDependencies": {
"@types/eslint": "^8.56.3",
"@types/node": "17.0.21",
"@types/react": "17.0.39",
"eslint": "8.10.0",
Expand Down
1 change: 1 addition & 0 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"lint": "eslint src"
},
"eslintConfig": {
"root": true,
"extends": [
"react-app",
"react-app/jest"
Expand Down
9 changes: 9 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('prettier').Config} */
module.exports = {
trailingComma: 'es5',
bracketSpacing: true,
tabWidth: 2,
semi: false,
singleQuote: true,
arrowParens: 'always',
};
mudetroit marked this conversation as resolved.
Show resolved Hide resolved
Loading