Skip to content

Commit

Permalink
Standardise repo per module template as of July 2023 (#139)
Browse files Browse the repository at this point in the history
* Standardise repo per module template as of July 2023

* Remove unused workflow and add pull request template

* Fix simple-git-hooks installation

* Fix @types/node version
  • Loading branch information
Mrtenz authored Jul 12, 2023
1 parent 501fe9e commit a762e02
Show file tree
Hide file tree
Showing 32 changed files with 3,041 additions and 2,093 deletions.
12 changes: 12 additions & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ignores": [
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@metamask/auto-changelog",
"@types/*",
"prettier-plugin-packagejson",
"simple-git-hooks",
"ts-node",
"typedoc"
]
}
40 changes: 11 additions & 29 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ module.exports = {
},

overrides: [
{
files: ['*.d.ts'],
rules: {
'import/unambiguous': 'off',
},
},

{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],

// This rule is copied from the base config, but changed to allow for
// `snake_case` properties. This is because we use those a lot in this
// repository, and replacing them would be a breaking change.
Expand Down Expand Up @@ -81,27 +72,18 @@ module.exports = {

{
files: ['*.test.ts', '*.test.js'],
extends: ['@metamask/eslint-config-jest'],
},

// Allow expect(value).toMatchSnapshot in this file only
{
files: ['./test/reference-implementations.test.ts'],
rules: {
'jest/no-restricted-matchers': [
'error',
{
resolves: 'Use `expect(await promise)` instead.',
toBeFalsy: 'Avoid `toBeFalsy`',
toBeTruthy: 'Avoid `toBeTruthy`',
// toMatchSnapshot: ...
toThrowErrorMatchingSnapshot:
'Use `toThrowErrorMatchingInlineSnapshot()` instead',
},
],
},
extends: [
'@metamask/eslint-config-jest',
'@metamask/eslint-config-nodejs',
],
},
],

ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'dist/', 'docs/'],
ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'dist/',
'docs/',
'.yarn/',
],
};
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* text=auto

yarn.lock linguist-generated=false

# yarn v3
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
/.yarn/releases/** binary
/.yarn/plugins/** binary
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
Are there any issues or other links reviewers should consult to understand this pull request better? For instance:
* Fixes #12345
* See: #67890
-->
124 changes: 124 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --immutable

build-source:
name: Build source
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build:source
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
build-types:
name: Build types
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build:types
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
lint:
name: Lint
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn auto-changelog validate --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn auto-changelog validate
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
test:
name: Test
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
148 changes: 0 additions & 148 deletions .github/workflows/build-test.yml

This file was deleted.

Loading

0 comments on commit a762e02

Please sign in to comment.