Skip to content

Commit

Permalink
refactor: sync with upstream template, remove unused/unnecessary deps
Browse files Browse the repository at this point in the history
- Sync package.json and tsconfig.json with upstream template
- Add GitHub Action that ensures the dist is correct
- Remove Jest and its related dependencies
- Remove unnecessary ESLint plugins/rules
- Use default Prettier settings
  • Loading branch information
benelan committed Jan 24, 2024
1 parent 102206f commit ae5c20e
Show file tree
Hide file tree
Showing 14 changed files with 2,266 additions and 10,229 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist/
lib/
node_modules/
jest.config.js
55 changes: 0 additions & 55 deletions .eslintrc.json

This file was deleted.

75 changes: 75 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
env:
node: true
es6: true

globals:
Atomics: readonly
SharedArrayBuffer: readonly

ignorePatterns:
- "!.*"
- "**/node_modules/.*"
- "**/dist/.*"
- "*.json"

parser: "@typescript-eslint/parser"

parserOptions:
ecmaVersion: 2023
sourceType: module
project:
- "./tsconfig.json"

plugins:
- "@typescript-eslint"
- "github"

extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- prettier

rules:
{
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type":
["error", { "allowExpressions": true }],
"@typescript-eslint/explicit-member-accessibility":
["error", { "accessibility": "no-public" }],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"camelcase": "off",
"eslint-comments/no-unused-disable": "off",
"eslint-comments/no-use": "off",
"i18n-text/no-en": "off",
"import/no-namespace": "off",
"no-console": "off",
"no-unused-vars": "off",
}
65 changes: 65 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# In TypeScript actions, `dist/index.js` is a special file. When you reference
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
# project, the `dist/index.js` file is generated from other source files through
# the build process. We need to make sure that the checked-in `dist/index.js`
# file matches what is expected from the build.
#
# This workflow will fail if the checked-in `dist/index.js` file does not match
# what is expected from the build.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest

permissions:
contents: read
statuses: write

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install Dependencies
id: install
run: npm ci

- name: Build dist/ Directory
id: build
run: npm run bundle

- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
11 changes: 1 addition & 10 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
{}
6 changes: 0 additions & 6 deletions __test__/main.test.ts

This file was deleted.

152 changes: 80 additions & 72 deletions dist/index.js

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

Loading

0 comments on commit ae5c20e

Please sign in to comment.