Skip to content

Commit

Permalink
build!: transmute codebase to TypeScript (#96)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: minimum recommended node version bumped from
10.13.0 to 14.20.0
  • Loading branch information
Xunnamius committed Dec 8, 2022
1 parent f9ad903 commit 5f588e9
Show file tree
Hide file tree
Showing 106 changed files with 41,284 additions and 1,825 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage:
range: '75...100'
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 2
50 changes: 50 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# When running a (projector) pipeline via GHA/Vercel, all required env vars must
# be defined as repo secrets. With projector, the sync command handles this.

# Codecov test analysis token
#
# Required: if deploying
# Matches: ^[a-f0-9-]+$
# On-Sync: mirror
#
# The token used during CI/CD to analyze and upload build artifact code quality
# data to Codecov.
CODECOV_TOKEN=

# GitHub deploy token
#
# Alias: GH_TOKEN
# Required: if deploying
# Matches: ^[a-f0-9]+$
# On-Sync: mirror
#
# The token used during CI/CD to interact with GitHub's API.
GITHUB_TOKEN=

# GPG private key passphrase
#
# Required: if deploying with CI/CD
# On-Sync: mirror
#
# The passphrase used to unlock GPG_PRIVATE_KEY. Not referenced during non-CI/CD
# (i.e. local, manual) deployments.
GPG_PASSPHRASE=

# GPG private key
#
# Required: if deploying with CI/CD
# On-Sync: mirror
#
# The GPG key used to sign all git commits and releases. Not referenced during
# non-CI/CD (i.e. local, manual) deployments.
GPG_PRIVATE_KEY=

# NPM deploy token
#
# Required: if deploying with CI/CD
# Matches: ^[a-f0-9-]+$
# On-Sync: mirror
#
# The token used during CD to login to NPM. Not referenced during non-CI/CD
# (i.e. local, manual) deployments.
NPM_TOKEN=
171 changes: 171 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
'use strict';

const plugins = ['unicorn', '@typescript-eslint', 'import'];

const xtends = [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:unicorn/recommended'
];

const environment = {
es2022: true,
node: true
// * Instead of including more options here, enable them on a per-file basis
};

const rules = {
'no-console': 'warn',
'no-return-await': 'warn',
'no-await-in-loop': 'warn',
'import/no-unresolved': ['error', { commonjs: true }],
'no-extra-boolean-cast': 'off',
'no-empty': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/ban-ts-comment': [
'warn',
{
'ts-expect-error': 'allow-with-description',
minimumDescriptionLength: 6
}
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_+',
varsIgnorePattern: '^_+',
caughtErrorsIgnorePattern: '^ignored?\\d*$',
caughtErrors: 'all'
}
],
// ? Ever since v4, we will rely on TypeScript to catch these
'no-undef': 'off',
'@typescript-eslint/no-var-requires': 'off',
// ? I'll be good, I promise
'@typescript-eslint/no-non-null-assertion': 'off',
'no-unused-vars': 'off',
'unicorn/no-keyword-prefix': 'warn',
'unicorn/prefer-string-replace-all': 'warn',
// ? Handled by integration tests
'unicorn/prefer-module': 'off',
// ? I am of the opinion that there is a difference between something being
// ? defined as nothing and something being undefined
'unicorn/no-null': 'off',
// ? If MongoDB can get away with "DB" in its name, so can we. Also,
// ? unnecessary underscores are a big no-no.
'unicorn/prevent-abbreviations': [
'warn',
{
checkFilenames: false,
replacements: {
args: false,
str: false,
fn: false,
db: false,
dir: false,
dist: false,
tmp: false,
pkg: false,
src: false,
dest: false,
obj: false,
val: false
},
ignore: [/stderr/i]
}
],
// ? Actually, I rather like this curt syntax
'unicorn/no-await-expression-member': 'off',
// ? Between disabling this and disabling no-empty-function, I choose this
'unicorn/no-useless-undefined': 'off',
// ? Not sure why this isn't the default
'unicorn/prefer-export-from': ['warn', { ignoreUsedVariables: true }],
// ? Yeah, I read The Good Parts too, I know what I'm doing
'unicorn/consistent-function-scoping': 'off',
// ? It's 2022. Use Prettier
'unicorn/no-nested-ternary': 'off',
// ? `Array.from` communicates intent much better than `[...]`
'unicorn/prefer-spread': 'off',
// ? Not realistic when using TypeScript
'unicorn/prefer-native-coercion-functions': 'off',
// ? Premature optimization is evil
'unicorn/no-array-for-each': 'off',
// ? Lol, no
'unicorn/explicit-length-check': 'off',
// ? I don't think so
'unicorn/no-negated-condition': 'off'
};

module.exports = {
parser: '@typescript-eslint/parser',
plugins,
extends: xtends,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
impliedStrict: true,
jsx: true
},
project: 'tsconfig.eslint.json'
},
env: environment,
rules,
overrides: [
{
files: ['*.test.*'],
plugins: [...plugins, 'jest'],
env: { ...environment, jest: true },
extends: [...xtends, 'plugin:jest/all', 'plugin:jest/style'],
rules: {
...rules,
'jest/lowercase': 'off',
'jest/consistent-test-it': 'off',
'jest/require-top-level-describe': 'off',
'jest/valid-describe': 'off',
'jest/no-hooks': 'off',
'jest/require-to-throw-message': 'off',
'jest/prefer-called-with': 'off',
'jest/prefer-spy-on': 'off',
'jest/no-if': 'off',
'jest/no-disabled-tests': 'warn',
'jest/no-commented-out-tests': 'warn',
'jest/no-alias-methods': 'off',
'jest/max-expects': 'off',
'jest/prefer-mock-promise-shorthand': 'off',
'jest/no-conditional-in-test': 'off',
'jest/no-conditional-expect': 'off',
'jest/prefer-each': 'off'
}
}
],
settings: {
react: {
version: 'detect'
},
'import/extensions': ['.ts', '.tsx', '.js', '.jsx'],
// ? Switch parsers depending on which type of file we're looking at
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.cts', '.mts'],
'@babel/eslint-parser': ['.js', '.jsx', '.cjs', '.mjs']
},
'import/resolver': {
node: {},
typescript: {}
},
'import/ignore': [
// ? Don't go complaining about anything that we don't own
'.*/node_modules/.*',
'.*/bin/.*'
]
},
ignorePatterns: ['coverage', 'dist', 'fixtures', '__fixtures__', '__snapshots__']
};
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
commit-message:
prefix: 'chore'
prefix-development: 'chore'
include: 'scope'

- package-ecosystem: npm
directory: /
schedule:
interval: daily
commit-message:
prefix: 'build'
prefix-development: 'chore'
include: 'scope'
Empty file added .github/workflows/.gitkeep
Empty file.
19 changes: 13 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
*.ignore
*.ignore.*
ignore.*
*.tsbuildinfo
dist
build
.vscode
!.vscode/launch.json
.vercel
.env
.npmrc
external-scripts/bin
next-env.d.ts
node_modules
coverage
dist
.DS_Store

# these cause more harm than good
# when working with contributors
package-lock.json
yarn.lock
7 changes: 7 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

npx commitlint -e
if [ -z $GAC_VERIFY_SIMPLE ]; then npm run test; fi
echo
node spellcheck-commit.js
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

if [ -z $GAC_VERIFY_SIMPLE ]; then npm run lint; fi
NODE_ENV=format npx lint-staged --concurrent false
1 change: 0 additions & 1 deletion .huskyrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// * https://www.npmjs.com/package/npm-check-updates#configuration-files

module.exports = {
reject: [
// ? Pin the CJS version of strip-indent
'strip-indent',
// ? Pin the CJS version of execa
'execa'
]
};
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

10 changes: 8 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Paths below are ignored by prettier as well as remark and doctoc when called
# with npm run format)
build
external-scripts/bin
node_modules
coverage
dist

coverage
package-lock.json
fixtures
docs
CHANGELOG.md
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

Loading

0 comments on commit 5f588e9

Please sign in to comment.