Skip to content

Commit

Permalink
Migrate to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
e-adrien committed May 15, 2024
1 parent 476ca8c commit d2e5b5a
Show file tree
Hide file tree
Showing 28 changed files with 955 additions and 514 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.yml]
indent_style = space
indent_size = 2

[*.{cjs,js,ts}]
indent_style = space
indent_size = 2
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated files
tsconfig.tsbuildinfo
dist/

# Yarn & node.js dependencies
package.json
node_modules/
.pnp.*
.yarn/*
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable no-undef */
module.exports = {
root: true,
env: {
es2022: true,
browser: true,
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
24 changes: 24 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": ["config:recommended", ":semanticCommits"],
"timezone": "Europe/Paris",
"schedule": ["before 4:00 am on the first day of the month"],
"rangeStrategy": "bump",
"packageRules": [
{
"matchDatasources": ["npm"],
"minimumReleaseAge": "3 days"
},
{
"matchDatasources": ["npm"],
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["minor", "patch"],
"groupName": "all non-major dependencies",
"groupSlug": "all-minor-patch",
"automerge": true,
"automergeType": "pr",
"automergeStrategy": "squash"
}
],
"ignoreDeps": [],
"ignorePaths": []
}
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: "20 18 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
27 changes: 27 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Package to npmjs

on:
release:
types: [created]

jobs:
publish:
name: Publish Package to npmjs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- run: npm install

- run: npm run build

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/quality-control.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: QC Checks

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
checks:
name: QC Checks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install
run: npm install

- name: ESLint checks
run: npm run eslint-check

- name: Prettier checks
run: npm run prettier-check

- name: Build
run: npm run build

tests:
name: Tests Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- uses: microsoft/playwright-github-action@v1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: npm install

- name: Run tests
run: npm run test
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated files
tsconfig.tsbuildinfo
dist/

# Yarn & node.js dependencies
node_modules/
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Yarn lockfile
yarn.lock

# OS X
.DS_Store
._*
.Spotlight-V100
.Trashes
.~lock.*
4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extension": ["ts"],
"spec": "tests/**/*.spec.ts"
}
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.github
.vscode
.yarn
node_modules
.editorconfig
.eslintignore
.eslintrc.cjs
.gitattributes
.gitignore
.prettierignore
.prettierrc.cjs
.whitesource
.yarnrc.yml
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated files
tsconfig.tsbuildinfo
dist/

# Yarn & node.js dependencies
package.json
node_modules/
.pnp.*
.yarn/*
18 changes: 18 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
printWidth: 120,
trailingComma: "es5",
overrides: [
{
files: [".eslintrc.*", ".prettierrc.*", "*.json", "*.md"],
options: {
printWidth: 80,
},
},
{
files: ["tsconfig.json"],
options: {
trailingComma: "none",
},
},
],
};
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Tests",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/mocha",
"runtimeArgs": [],
"outputCapture": "std",
"skipFiles": ["<node_internals>/**/*.js"],
"env": {
"NODE_OPTIONS": "--loader=ts-node/esm"
}
}
]
}
40 changes: 40 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"search.exclude": {
"**/.git/**": true,
"**/node_modules/**": true,
"**/.yarn/**": true,
"**/dist/**": true
},
"files.exclude": {
"**/.git/**": true,
"**/node_modules/**": true,
"**/.yarn/**": true,
"**/dist/**": true
},
"files.watcherExclude": {
"**/.git/**": true,
"**/node_modules/**": true,
"**/.yarn/**": true,
"**/dist/**": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"eslint.enable": true,
"eslint.format.enable": true,
"prettier.configPath": ".prettierrc.cjs",
"prettier.ignorePath": ".prettierignore"
}
12 changes: 12 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scanSettings": {
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: true

enableScripts: true

nodeLinker: node-modules
Loading

0 comments on commit d2e5b5a

Please sign in to comment.