Skip to content

Commit

Permalink
chore(frontend): set up typerscript
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Sep 4, 2024
1 parent ab050f7 commit 30489da
Show file tree
Hide file tree
Showing 11 changed files with 795 additions and 56 deletions.
2 changes: 1 addition & 1 deletion frontend/.ember-cli
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript
rather than JavaScript by default, when a TypeScript version of a given blueprint is available.
*/
"isTypeScriptProject": false
"isTypeScriptProject": true
}
112 changes: 101 additions & 11 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,107 @@
"use-strict";

module.exports = {
extends: ["@adfinis/eslint-config/ember-app"],
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
},
plugins: ["ember", "@typescript-eslint", "import"],
extends: [
"eslint:recommended",
"plugin:ember/recommended",
"plugin:prettier/recommended",
],
env: {
browser: true,
},
rules: {
"ember/no-actions-hash": "warn",
"ember/no-component-lifecycle-hooks": "warn",
"ember/no-mixins": "warn",
"ember/no-new-mixins": "warn",
"ember/no-classic-classes": "warn",
"ember/no-classic-components": "warn",
"ember/no-get": "warn",
"ember/no-observers": "warn",
"qunit/no-assert-equal": "warn",
"ember/require-tagless-components": "warn",
// possible errors
"no-await-in-loop": "error",

// best practices
"array-callback-return": "error",
"dot-notation": "error",
eqeqeq: "error",
"no-alert": "error",
"no-else-return": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-floating-decimal": "error",
"one-var": ["error", "never"],
curly: ["error", "multi-line"],

// ES6
"no-var": "error",
"object-shorthand": "error",
"prefer-const": "error",
"prefer-destructuring": [
"error",
{ AssignmentExpression: { array: false, object: false } },
],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",

// import
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/order": [
"error",
{
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: true },
},
],

// tooling
"no-console": ["error", { allow: ["warn", "error"] }],
"no-debugger": "error",
},
overrides: [
// js files
{
files: ["**/*.js"],
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {},
},
// ts files
{
files: ["**/*.ts"],
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {},
},
// node files
{
files: [
"./.eslintrc.js",
"./.prettierrc.js",
"./.stylelintrc.js",
"./.template-lintrc.js",
"./ember-cli-build.js",
"./testem.js",
"./blueprints/*/index.js",
"./config/**/*.js",
"./lib/*/index.js",
"./server/**/*.js",
],
env: {
browser: false,
node: true,
},
extends: ["plugin:n/recommended"],
},
{
// test files
files: ["tests/**/*-test.{js,ts}"],
extends: ["plugin:qunit/recommended"],
},
],
};
1 change: 1 addition & 0 deletions frontend/app/components/task-selection/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class TaskSelectionComponent extends Component {
this._setInitial();

if (this.args.task) {
console.log("foo");

Check failure on line 59 in frontend/app/components/task-selection/component.js

View workflow job for this annotation

GitHub Actions / lint (js)

Unexpected console statement
this.onTaskChange(this.args.task, { preventAction: true });
}

Expand Down
14 changes: 14 additions & 0 deletions frontend/app/config/environment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Type declarations for
* import config from 'my-app/config/environment'
*/
declare const config: {
environment: string;
modulePrefix: string;
podModulePrefix: string;
locationType: "history" | "hash" | "none" | "auto";
rootURL: string;
APP: Record<string, unknown>;
};

export default config;
1 change: 1 addition & 0 deletions frontend/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const EmberApp = require("ember-cli/lib/broccoli/ember-app");

module.exports = function (defaults) {
const app = new EmberApp(defaults, {
"ember-cli-babel": { enableTypescriptTransform: true },
babel: {
plugins: [
require.resolve("ember-concurrency/async-arrow-task-transform"),
Expand Down
37 changes: 35 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint . --config-path .template-lintrc-ci.js",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint --config .eslintrc.js .",
"lint:js:fix": "eslint --config .eslintrc.js . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"start": "ember server --proxy https://timed.localhost --secure-proxy=false",
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"test:ember": "ember test"
Expand All @@ -44,6 +45,37 @@
"@glimmer/tracking": "1.1.2",
"@html-next/vertical-collection": "4.0.2",
"@sentry/ember": "^7.98.0",
"@tsconfig/ember": "^3.0.8",
"@tsconfig/strictest": "^2.0.5",
"@types/ember": "^4.0.11",
"@types/ember-data": "^4.4.16",
"@types/ember-data__adapter": "^4.0.6",
"@types/ember-data__model": "^4.0.5",
"@types/ember-data__serializer": "^4.0.6",
"@types/ember-data__store": "^4.0.7",
"@types/ember-qunit": "^6.1.1",
"@types/ember-resolver": "^9.0.0",
"@types/ember__application": "^4.0.11",
"@types/ember__array": "^4.0.10",
"@types/ember__component": "^4.0.22",
"@types/ember__controller": "^4.0.12",
"@types/ember__debug": "^4.0.8",
"@types/ember__destroyable": "^4.0.5",
"@types/ember__engine": "^4.0.11",
"@types/ember__error": "^4.0.6",
"@types/ember__object": "^4.0.12",
"@types/ember__polyfills": "^4.0.6",
"@types/ember__routing": "^4.0.22",
"@types/ember__runloop": "^4.0.10",
"@types/ember__service": "^4.0.9",
"@types/ember__string": "^3.0.15",
"@types/ember__template": "^4.0.7",
"@types/ember__test": "^4.0.6",
"@types/ember__utils": "^4.0.7",
"@types/qunit": "^2.19.10",
"@types/rsvp": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"broccoli-asset-rev": "^3.0.0",
"broccoli-funnel": "^3.0.8",
"concurrently": "^8.0.1",
Expand Down Expand Up @@ -125,6 +157,7 @@
"stylelint-scss": "^6.3.0",
"tracked-built-ins": "3.1.1",
"tracked-toolbox": "2.0.0",
"typescript": "^5.5.4",
"webpack": "5.92.1"
},
"engines": {
Expand Down
Loading

0 comments on commit 30489da

Please sign in to comment.