From 0a0dd1f23d268226a292d1aaa2fe5b70681a6804 Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Sat, 24 Feb 2024 02:32:24 -0300 Subject: [PATCH 1/5] Added prettier configuration --- .prettierignore | 10 ++++++++++ .vscode/settings.json | 38 ++++++++++++++++++++++++++++++++++++++ prettier.config.js | 9 +++++++++ 3 files changed, 57 insertions(+) create mode 100644 .prettierignore create mode 100644 .vscode/settings.json create mode 100644 prettier.config.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..651ab83 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,10 @@ +.github +.next +build +bundles +coverage +dist +lib +node_modules +out +public diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..192c739 --- /dev/null +++ b/.vscode/settings.json @@ -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 +} diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..abaf674 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,9 @@ +/** @type {import('prettier').Config} */ +module.exports = { + trailingComma: 'es5', + bracketSpacing: true, + tabWidth: 2, + semi: false, + singleQuote: true, + arrowParens: 'always', +}; From f777c2810172d2ff41ec2350d3bf3ba203b31ccb Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Fri, 23 Feb 2024 21:33:07 -0300 Subject: [PATCH 2/5] Fix eslint+babel config, add eslint ignore --- .eslintignore | 10 ++++++ examples/create-react-app/package.json | 1 + examples/nextjs/.eslintrc.json | 3 -- examples/nextjs/babel.config.js | 1 + examples/nextjs/eslint.config.js | 6 ++++ examples/nextjs/package-lock.json | 45 ++++++++++++++++++++++++++ examples/nextjs/package.json | 1 + examples/typescript/package.json | 1 + 8 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 .eslintignore delete mode 100644 examples/nextjs/.eslintrc.json create mode 100644 examples/nextjs/babel.config.js create mode 100644 examples/nextjs/eslint.config.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..651ab83 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,10 @@ +.github +.next +build +bundles +coverage +dist +lib +node_modules +out +public diff --git a/examples/create-react-app/package.json b/examples/create-react-app/package.json index fe33a1b..4473755 100644 --- a/examples/create-react-app/package.json +++ b/examples/create-react-app/package.json @@ -21,6 +21,7 @@ "eject": "react-scripts eject" }, "eslintConfig": { + "root": true, "extends": [ "react-app", "react-app/jest" diff --git a/examples/nextjs/.eslintrc.json b/examples/nextjs/.eslintrc.json deleted file mode 100644 index bffb357..0000000 --- a/examples/nextjs/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/examples/nextjs/babel.config.js b/examples/nextjs/babel.config.js new file mode 100644 index 0000000..4ba52ba --- /dev/null +++ b/examples/nextjs/babel.config.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/examples/nextjs/eslint.config.js b/examples/nextjs/eslint.config.js new file mode 100644 index 0000000..632c2b9 --- /dev/null +++ b/examples/nextjs/eslint.config.js @@ -0,0 +1,6 @@ +/** @type {import('eslint').Linter.Config} */ +module.exports = { + root: true, + extends: 'next/core-web-vitals', + ignorePatterns: ['node_modules'], +} diff --git a/examples/nextjs/package-lock.json b/examples/nextjs/package-lock.json index a8ed179..3813b69 100644 --- a/examples/nextjs/package-lock.json +++ b/examples/nextjs/package-lock.json @@ -15,6 +15,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", @@ -409,6 +410,28 @@ "integrity": "sha512-JLo+Y592QzIE+q7Dl2pMUtt4q8SKYI5jDrZxrozEQxnGVOyYE+GWK9eLkwTaeN9DDctlaRAQ3TBmzZ1qdLE30A==", "dev": true }, + "node_modules/@types/eslint": { + "version": "8.56.3", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.3.tgz", + "integrity": "sha512-PvSf1wfv2wJpVIFUMSb+i4PvqNYkB9Rkp9ZDO3oaWzq4SKhsQk4mrMBr3ZH06I0hKrVGLBacmgl8JM4WVjb9dg==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3259,6 +3282,28 @@ "integrity": "sha512-JLo+Y592QzIE+q7Dl2pMUtt4q8SKYI5jDrZxrozEQxnGVOyYE+GWK9eLkwTaeN9DDctlaRAQ3TBmzZ1qdLE30A==", "dev": true }, + "@types/eslint": { + "version": "8.56.3", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.3.tgz", + "integrity": "sha512-PvSf1wfv2wJpVIFUMSb+i4PvqNYkB9Rkp9ZDO3oaWzq4SKhsQk4mrMBr3ZH06I0hKrVGLBacmgl8JM4WVjb9dg==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index 51da7a3..8ce69d1 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -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", diff --git a/examples/typescript/package.json b/examples/typescript/package.json index b561232..f51748b 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -27,6 +27,7 @@ "lint": "eslint src" }, "eslintConfig": { + "root": true, "extends": [ "react-app", "react-app/jest" From 843be6c9888e0b71ea254f829d06491c6354e454 Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Mon, 26 Feb 2024 13:44:12 -0300 Subject: [PATCH 3/5] New CI with updated action versions, cache and linters --- .github/workflows/ci.yaml | 58 ++++++++++++++++++++++++++-------- .github/workflows/publish.yaml | 26 +++++++-------- 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2077320..3efe348 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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: true + eslint: true + eslint_args: '--max-warnings 0' + eslint_extensions: js,jsx,ts,tsx + + - name: Test + run: npm run test diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 444484d..4f40bdf 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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 }} From 53c061c1fc99c078cf90fdb0e7210738422ba515 Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Sat, 24 Feb 2024 14:56:22 -0300 Subject: [PATCH 4/5] Disable lint for this PR, to be enabled post-lint fixes and formatting --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3efe348..755a2cb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,8 +48,8 @@ jobs: uses: wearerequired/lint-action@v2 with: github_token: ${{ secrets.GITHUB_TOKEN }} - prettier: true - eslint: true + prettier: false + eslint: false eslint_args: '--max-warnings 0' eslint_extensions: js,jsx,ts,tsx From 9c2f5c55b2419c068e9f132d609ed8681ac88d7f Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Mon, 26 Feb 2024 14:53:30 -0300 Subject: [PATCH 5/5] Bumped node version in publish ci from 12 to 14 --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 4f40bdf..e66bdee 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,7 +10,7 @@ jobs: # Setup .npmrc file to publish to GitHub Packages - uses: actions/setup-node@v2 with: - node-version: "12.x" + node-version: "14.x" registry-url: "https://registry.npmjs.org" # Defaults to the user or organization that owns the workflow file # scope: '@rollbar'