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

Migrate to TypeScript #1046

Merged
merged 9 commits into from
May 6, 2023
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
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/new-sheep-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ancesdir": major
---

Migrated to TypeScript and added new release process. Although this is functionally equivalent, the change from flow types to TypeScript could be a breaking change for folks development workflows, so this is a major release.
130 changes: 130 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
module.exports = {
extends: ["@khanacademy"],
plugins: ["eslint-comments", "import", "jest", "@babel"],
rules: {
"constructor-super": "error",
curly: "error",
eqeqeq: ["error", "allow-null"],
"generator-star-spacing": "error",
"guard-for-in": "error",
"linebreak-style": ["error", "unix"],
"no-alert": "error",
"no-array-constructor": "error",
"no-console": "error",
"no-debugger": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-extra-bind": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-throw-literal": "error",
"@babel/no-invalid-this": "error",
"no-with": "error",
"no-async-promise-executor": "error",
"no-const-assign": "error",
"no-else-return": [
"error",
{
allowElseIf: false,
},
],
"no-irregular-whitespace": "off",
"no-multi-str": "error",
"no-prototype-builtins": "off",
"no-restricted-syntax": [
"error",
{
selector: "IntersectionTypeAnnotation",
message:
"Use exact object types and the spread operator instead",
},
],
"no-return-await": "error",
"no-this-before-super": "error",
"no-useless-catch": "off",
"no-useless-call": "error",
"no-undef": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unused-expressions": "error",
"no-unused-vars": ["error", {args: "none", varsIgnorePattern: "^_*$"}],
"no-var": "error",
"one-var": ["error", "never"],
"prefer-const": "error",
"prefer-spread": "error",
"require-await": "error",
"require-yield": "error",

// We turned this off because it complains when you have a
// multi-line string, which I think is going too far.
"prefer-template": "off",
// We've decided explicitly not to care about this.
"arrow-parens": "off",
// ES6/jsx stuff that's disabled for now, but maybe shouldn't be.
// TODO(csilvers): enable these if/when community agrees on it.
"prefer-arrow-callback": "off",

// Stuff that's disabled for now, but maybe shouldn't be.
// TODO(jeresig): It's an anti-pattern but it appears to be used
// frequently in reducers, the alternative would be super-clunky.
"no-case-declarations": "off",
// TODO(csilvers): enable these if/when community agrees on it.
// Might be nice to turn this on one day, but since we don't
// use jsdoc anywhere it seems silly to require it yet.
"valid-jsdoc": "off",
"require-jsdoc": "off",

// eslint-comments
"eslint-comments/no-unlimited-disable": "error",
"eslint-comments/no-unused-disable": "error",

// import
"import/extensions": [
"error",
"never",
{
ignorePackages: true,
},
],
"import/no-cycle": [
"error",
{
ignoreExternal: true,
commonjs: true,
maxDepth: 6,
},
],
"import/named": "error",
"import/default": "error",
"import/namespace": "error",
"import/no-unassigned-import": [
"error",
{
allow: ["@jest/globals", "jest-extended"],
},
],

// jest
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-contain": "error",
"jest/prefer-to-have-length": "error",
"jest/valid-title": "error",

// prettier
"prettier/prettier": [
"error",
{
tabWidth: 4,
trailingComma: "all",
bracketSpacing: false,
},
],
},
env: {
es6: true,
jest: true,
node: true,
},
};
43 changes: 0 additions & 43 deletions .eslintrc.json

This file was deleted.

15 changes: 0 additions & 15 deletions .flowconfig

This file was deleted.

31 changes: 15 additions & 16 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ on:
pull_request:
branches:
- main
- changeset-release/*

push:
branches:
- main
- changeset-release/*

jobs:
lint:
name: Lint and flow check
name: Lint and type check
env:
CI: true
runs-on: ${{ matrix.os }}
Expand All @@ -21,17 +23,18 @@ jobs:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Flow
run: yarn flow:ci

- name: Types
run: yarn typecheck
- uses: Khan/actions@check-for-changeset-v0
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
with:
exclude: .github/,.storybook/

coverage:
name: Update test coverage
Expand All @@ -44,12 +47,10 @@ jobs:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
- name: Run tests with coverage
run: yarn coverage
- name: Upload coverage
Expand All @@ -70,11 +71,9 @@ jobs:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
- name: Run tests and build
run: yarn build
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

on:
push:
branches:
- main

# This workflow will run changesets depending on two different scenarios:
#
# 1. If we are landing a specific commit into main (Author PR), then
# changesets will check if there are changes verifying the Markdown files
# generated automatically:
#
# a) There are new versions and there's NO Release PR, then the changesets
# action will create a new Release PR.
#
# b) There's a Release PR, then the changesets action will update the
# existing Release PR with the new commit.
#
# NOTE: (in both cases, changesets will modify the new version in
# package.json for each package, and will remove the MD files as part of the
# Release PR).
#
# 2. If we are landing the Release PR into main, then the changesets action
# will publish the changes to npm.
#
# For more info about this workflow, see:
# https://github.com/changesets/action#usage
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: 16.x

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn publish:ci
env:
# We use a Personal Access Token here rather than the GITHUB_TOKEN
# so that it will trigger our other actions. The token has to be on
# the account of someone with appropriate access levels and given the
# repo scope.
GITHUB_TOKEN: ${{ secrets.BOT_PA_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@khanacademy/eslint-config/.prettierrc");
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
]
Expand Down
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"editor.formatOnSave": true,
"javascript.validate.enable": false,
"typescript.validate.enable": false
}
Loading