mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-09 12:56:07 +08:00
Compile both JS and TS (#2464) by sondrekje
* Compile both JS and TS Builds upon Ferotiq's PR * Compile both JS and TS Builds upon Ferotiq's PR Co-authored-by: Miodec <bartnikjack@gmail.com>
This commit is contained in:
parent
db1aef58cc
commit
26c57d2ad3
11 changed files with 1058 additions and 20 deletions
|
|
@ -40,17 +40,7 @@
|
|||
"require-path-exists/exists": [
|
||||
2,
|
||||
{
|
||||
"extensions": [
|
||||
"",
|
||||
".js",
|
||||
".jsx",
|
||||
".es.js",
|
||||
".jsx",
|
||||
".json5",
|
||||
".es",
|
||||
".es6",
|
||||
".coffee"
|
||||
]
|
||||
"extensions": ["", ".ts", ".js", ".es.js", ".json5", ".es", ".es6"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
2
frontend/.eslintignore
Normal file
2
frontend/.eslintignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*.d.ts
|
||||
node_modules
|
||||
|
|
@ -12,9 +12,11 @@ var sass = require("gulp-sass")(require("dart-sass"));
|
|||
const replace = require("gulp-replace");
|
||||
const uglify = require("gulp-uglify");
|
||||
const through2 = require("through2");
|
||||
const tsify = require("tsify");
|
||||
// sass.compiler = require("dart-sass");
|
||||
|
||||
let eslintConfig = "../.eslintrc.json";
|
||||
let tsEslintConfig = "../ts.eslintrc.json";
|
||||
|
||||
task("clean", function () {
|
||||
return src(["./public/"], { allowEmpty: true }).pipe(vinylPaths(del));
|
||||
|
|
@ -27,6 +29,13 @@ task("lint-js", function () {
|
|||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
task("lint-ts", function () {
|
||||
return src("./src/js/**/*.ts")
|
||||
.pipe(eslint(tsEslintConfig))
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
task("lint-json", function () {
|
||||
return src("./static/**/*.json")
|
||||
.pipe(eslint(eslintConfig))
|
||||
|
|
@ -48,6 +57,7 @@ task("browserify", function () {
|
|||
plugins: ["@babel/transform-runtime"],
|
||||
})
|
||||
)
|
||||
.plugin(tsify)
|
||||
.bundle()
|
||||
.pipe(source("monkeytype.js"))
|
||||
.pipe(buffer());
|
||||
|
|
@ -76,8 +86,8 @@ task("sass", function () {
|
|||
});
|
||||
|
||||
task("updateSwCacheName", function () {
|
||||
let date = new Date();
|
||||
let dateString =
|
||||
const date = new Date();
|
||||
const dateString =
|
||||
date.getFullYear() +
|
||||
"-" +
|
||||
(date.getMonth() + 1) +
|
||||
|
|
@ -89,6 +99,7 @@ task("updateSwCacheName", function () {
|
|||
date.getMinutes() +
|
||||
"-" +
|
||||
date.getSeconds();
|
||||
|
||||
return src(["static/sw.js"])
|
||||
.pipe(
|
||||
replace(
|
||||
|
|
@ -98,7 +109,7 @@ task("updateSwCacheName", function () {
|
|||
)
|
||||
.pipe(
|
||||
through2.obj(function (file, enc, cb) {
|
||||
var date = new Date();
|
||||
const date = new Date();
|
||||
file.stat.atime = date;
|
||||
file.stat.mtime = date;
|
||||
cb(null, file);
|
||||
|
|
@ -111,6 +122,7 @@ task(
|
|||
"compile",
|
||||
series(
|
||||
"lint-js",
|
||||
"lint-ts",
|
||||
"lint-json",
|
||||
"browserify",
|
||||
"static",
|
||||
|
|
@ -122,6 +134,7 @@ task(
|
|||
task("watch", function () {
|
||||
watch("./src/sass/**/*.scss", series("sass"));
|
||||
watch("./src/js/**/*.js", series("lint-js", "browserify"));
|
||||
watch("./src/js/**/*.ts", series("lint-ts", "browserify"));
|
||||
watch("./static/**/*.*", series("lint-json", "static"));
|
||||
});
|
||||
|
||||
|
|
|
|||
132
frontend/package-lock.json
generated
132
frontend/package-lock.json
generated
|
|
@ -37,6 +37,7 @@
|
|||
"gulp-sass": "^5.0.0",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"through2": "^4.0.2",
|
||||
"tsify": "^5.0.4",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-paths": "^3.0.1",
|
||||
"vinyl-source-stream": "^2.0.0"
|
||||
|
|
@ -1960,6 +1961,12 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/any-promise": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
|
||||
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/anymatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
|
||||
|
|
@ -8179,6 +8186,18 @@
|
|||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-json": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
|
||||
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"error-ex": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-node-version": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
|
||||
|
|
@ -10081,6 +10100,58 @@
|
|||
"xtend": "~4.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tsconfig": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz",
|
||||
"integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"any-promise": "^1.3.0",
|
||||
"parse-json": "^2.2.0",
|
||||
"strip-bom": "^2.0.0",
|
||||
"strip-json-comments": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tsconfig/node_modules/strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tsify": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tsify/-/tsify-5.0.4.tgz",
|
||||
"integrity": "sha512-XAZtQ5OMPsJFclkZ9xMZWkSNyMhMxEPsz3D2zu79yoKorH9j/DT4xCloJeXk5+cDhosEibu4bseMVjyPOAyLJA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs.realpath": "^1.0.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"semver": "^6.1.0",
|
||||
"through2": "^2.0.0",
|
||||
"tsconfig": "^5.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"browserify": ">= 10.x",
|
||||
"typescript": ">= 2.8"
|
||||
}
|
||||
},
|
||||
"node_modules/tsify/node_modules/through2": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
|
||||
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"readable-stream": "~2.3.6",
|
||||
"xtend": "~4.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
|
|
@ -12091,6 +12162,12 @@
|
|||
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
|
||||
"dev": true
|
||||
},
|
||||
"any-promise": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
|
||||
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=",
|
||||
"dev": true
|
||||
},
|
||||
"anymatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
|
||||
|
|
@ -17114,6 +17191,15 @@
|
|||
"path-root": "^0.1.1"
|
||||
}
|
||||
},
|
||||
"parse-json": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
|
||||
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"error-ex": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"parse-node-version": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
|
||||
|
|
@ -18638,6 +18724,52 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"tsconfig": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz",
|
||||
"integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"any-promise": "^1.3.0",
|
||||
"parse-json": "^2.2.0",
|
||||
"strip-bom": "^2.0.0",
|
||||
"strip-json-comments": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"tsify": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tsify/-/tsify-5.0.4.tgz",
|
||||
"integrity": "sha512-XAZtQ5OMPsJFclkZ9xMZWkSNyMhMxEPsz3D2zu79yoKorH9j/DT4xCloJeXk5+cDhosEibu4bseMVjyPOAyLJA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs.realpath": "^1.0.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"semver": "^6.1.0",
|
||||
"through2": "^2.0.0",
|
||||
"tsconfig": "^5.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"through2": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
|
||||
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"readable-stream": "~2.3.6",
|
||||
"xtend": "~4.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
"gulp-sass": "^5.0.0",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"through2": "^4.0.2",
|
||||
"tsify": "^5.0.4",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-paths": "^3.0.1",
|
||||
"vinyl-source-stream": "^2.0.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import axios from "axios";
|
||||
|
||||
let apiPath = "";
|
||||
const apiPath = "";
|
||||
|
||||
let baseURL;
|
||||
if (window.location.hostname === "localhost") {
|
||||
|
|
@ -17,7 +17,7 @@ const axiosInstance = axios.create({
|
|||
// Request interceptor for API calls
|
||||
axiosInstance.interceptors.request.use(
|
||||
async (config) => {
|
||||
let idToken;
|
||||
let idToken: string | null;
|
||||
if (firebase.auth().currentUser != null) {
|
||||
idToken = await firebase.auth().currentUser.getIdToken();
|
||||
} else {
|
||||
1
frontend/src/js/modules.d.ts
vendored
Normal file
1
frontend/src/js/modules.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
declare var firebase: any;
|
||||
12
frontend/tsconfig.json
Normal file
12
frontend/tsconfig.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2015",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["./src/**/*.ts"],
|
||||
"files": ["./src/js/modules.d.ts"]
|
||||
}
|
||||
832
package-lock.json
generated
832
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,8 @@
|
|||
"npm": "8.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
||||
"@typescript-eslint/parser": "^5.11.0",
|
||||
"circular-dependency-plugin": "^5.2.2",
|
||||
"concurrently": "5.3.0",
|
||||
"eslint": "8.8.0",
|
||||
|
|
|
|||
61
ts.eslintrc.json
Normal file
61
ts.eslintrc.json
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"globals": {
|
||||
"firebase": "readonly",
|
||||
"$": "readonly",
|
||||
"moment": "readonly",
|
||||
"jQuery": "readonly",
|
||||
"html2canvas": "readonly",
|
||||
"ClipboardItem": "readonly",
|
||||
"grecaptcha": "readonly"
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:json/recommended",
|
||||
"plugin:require-path-exists/recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"plugins": ["json", "require-path-exists", "@typescript-eslint"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
"json/*": ["error"],
|
||||
"indent": ["off"], //handled by prettier
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double",
|
||||
{ "allowTemplateLiterals": true, "avoidEscape": true }
|
||||
],
|
||||
"semi": ["error", "always"],
|
||||
"no-unused-vars": ["error", { "argsIgnorePattern": "^(_|e|event)" }],
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"no-var": 2,
|
||||
"require-path-exists/notEmpty": 2,
|
||||
"require-path-exists/tooManyArguments": 2,
|
||||
"require-path-exists/exists": [
|
||||
2,
|
||||
{
|
||||
"extensions": [
|
||||
"",
|
||||
".ts",
|
||||
".tsx",
|
||||
".es.ts",
|
||||
".tsx",
|
||||
".json5",
|
||||
".es",
|
||||
".es6",
|
||||
".coffee"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue