Skip to content

Commit

Permalink
chore(typescript): test-app setup
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator committed Dec 22, 2024
1 parent e9171e9 commit d976b53
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 50 deletions.
22 changes: 0 additions & 22 deletions packages/test-app/.eslintignore

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions packages/test-app/app/controllers/index.js

This file was deleted.

20 changes: 20 additions & 0 deletions packages/test-app/app/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';

type Cookie = { name: string; value: any };

export default class IndexController extends Controller {
@service cookies!: any;

get allCookies(): Cookie[] {
this.cookies.write('now', new Date().getTime());

const cookies = this.cookies.read();
return Object.keys(cookies).reduce((acc, key) => {
let value = cookies[key];
acc.push({ name: key, value });

return acc;
}, [] as Cookie[]);
}
}
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion packages/test-app/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (environment) {
modulePrefix: 'test-app',
environment,
rootURL: '/',
locationType: 'auto',
locationType: 'hash',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
Expand Down
1 change: 1 addition & 0 deletions packages/test-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
let app = new EmberApp(defaults, {
'ember-cli-babel': { enableTypeScriptTransform: true },
// Add options here
});

Expand Down
5 changes: 3 additions & 2 deletions packages/test-app/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ember from 'eslint-plugin-ember';
import prettier from 'eslint-plugin-prettier/recommended';
import qunit from 'eslint-plugin-qunit';
import globals from 'globals';
import babelParser from '@babel/eslint-parser';
import typescriptParser from '@typescript-eslint/parser';
import n from 'eslint-plugin-n';
import js from '@eslint/js';

Expand Down Expand Up @@ -30,12 +30,13 @@ export default [
ember,
},

files: ['**/*.{ts,js}'],
languageOptions: {
globals: {
...globals.browser,
},

parser: babelParser,
parser: typescriptParser,
ecmaVersion: 2020,
sourceType: 'module',

Expand Down
10 changes: 9 additions & 1 deletion packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"repository": "https://github.com/simplabs/ember-cookies",
"scripts": {
"build": "ember build",
"lint": "pnpm lint:js",
"lint": "pnpm lint:js && pnpm lint:types",
"lint:fix": "pnpm lint:js:fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"nodetest": "node node-tests/runner.js",
"start": "ember server",
"test": "ember test",
Expand All @@ -33,6 +34,12 @@
"@eslint/js": "9.12.0",
"@glimmer/component": "2.0.0",
"@glimmer/tracking": "1.1.2",
"@glint/core": "^1.5.0",
"@glint/environment-ember-loose": "^1.5.0",
"@glint/environment-ember-template-imports": "^1.5.0",
"@tsconfig/ember": "^3.0.8",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"broccoli-asset-rev": "3.0.0",
"ember-auto-import": "2.8.1",
"ember-cli": "6.0.1",
Expand Down Expand Up @@ -69,6 +76,7 @@
"request": "2.88.2",
"rsvp": "4.8.5",
"symlink-or-copy": "1.3.1",
"typescript": "^5.7.2",
"webpack": "5.95.0"
},
"fastbootDependencies": [
Expand Down
19 changes: 19 additions & 0 deletions packages/test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "@tsconfig/ember/tsconfig.json",
"compilerOptions": {
// The combination of `baseUrl` with `paths` allows Ember's classic package
// layout, which is not resolvable with the Node resolution algorithm, to
// work with TypeScript.
"baseUrl": ".",
"experimentalDecorators": true,
"paths": {
"test-app/tests/*": ["tests/*"],
"test-app/*": ["app/*"],
"*": ["types/*"]
},
"types": [
"ember-source/types",
]
}
}

1 change: 1 addition & 0 deletions packages/test-app/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@glint/environment-ember-loose';
27 changes: 24 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d976b53

Please sign in to comment.