Skip to content

Commit 80bc2c2

Browse files
Add gts support (#1946)
* Add gts support * Lint setup * Prettier import sorting, more lint * Put lint config back * Fix lint * Remove NVP lint config * Remove prettier template lint
1 parent 0fd6ca8 commit 80bc2c2

File tree

108 files changed

+728
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+728
-391
lines changed

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = {
1818
'eslint:recommended',
1919
'plugin:ember/recommended',
2020
'plugin:prettier/recommended',
21-
'@clark/ember-order-imports',
2221
],
2322
env: {
2423
browser: true,
@@ -86,7 +85,7 @@ module.exports = {
8685
// Typescript files
8786
{
8887
parser: '@typescript-eslint/parser',
89-
files: ['app/**/*.ts', 'tests/**/*.ts'],
88+
files: ['app/**/*.{gts,ts}', 'tests/**/*.ts'],
9089
plugins: ['@typescript-eslint'],
9190
extends: ['plugin:@typescript-eslint/recommended'],
9291
rules: {

.prettierignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@
1111

1212
# ember-try
1313
/.node_modules.ember-try/
14+
15+
# ember-electron
16+
/electron-app/node_modules/
17+
/electron-app/out/
18+
/electron-app/ember-dist/
19+
/electron-app/ember-test/
20+
21+
# Sentry
22+
/electron-app/sentry-symbols.js
23+
24+
# Types
25+
/types/

.prettierrc.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,73 @@
11
'use strict';
22

3+
const testing = [
4+
'^ember-cli-htmlbars($|\\/)',
5+
'^qunit',
6+
'^ember-qunit',
7+
'^@ember/test-helpers',
8+
'^ember-exam',
9+
'^ember-cli-mirage',
10+
'^sinon',
11+
'^ember-sinon-qunit',
12+
'^(@[^\\/]+\\/)?[^\\/]+\\/test-support($|\\/)',
13+
].join('|');
14+
15+
const emberCore = [
16+
'^ember$',
17+
'^@ember\\/',
18+
'^ember-data($|\\/)',
19+
'^@ember-data\\/',
20+
'^@glimmer\\/',
21+
'^require$',
22+
].join('|');
23+
24+
const emberAddons = ['^@?ember-', '^@[^\\/]+\\/ember($|\\/|-)'].join('|');
25+
26+
const swachInternals = ['^swach/(.*)$', '^[./]'].join('|');
27+
28+
const importOrder = [
29+
testing,
30+
emberCore,
31+
emberAddons,
32+
'<THIRD_PARTY_MODULES>',
33+
swachInternals,
34+
];
35+
const importOrderParserPlugins = ['typescript', 'decorators-legacy'];
36+
const importOrderSeparation = true;
37+
const importOrderSortSpecifiers = true;
38+
339
module.exports = {
40+
plugins: [
41+
'prettier-plugin-ember-template-tag',
42+
require('@trivago/prettier-plugin-sort-imports'),
43+
],
44+
importOrder,
45+
importOrderParserPlugins,
46+
importOrderSeparation,
47+
importOrderSortSpecifiers,
448
overrides: [
549
{
6-
files: '*.{js,ts}',
50+
files: ['**/*.hbs'],
51+
options: {
52+
singleQuote: false,
53+
},
54+
},
55+
{
56+
files: '*.{js,ts,gjs,gts}',
57+
options: {
58+
singleQuote: true,
59+
},
60+
},
61+
{
62+
files: '*.{yaml,yml}',
763
options: {
864
singleQuote: true,
965
},
1066
},
1167
],
1268
};
69+
70+
exports.importOrder = importOrder;
71+
exports.importOrderParserPlugins = importOrderParserPlugins;
72+
exports.importOrderSeparation = importOrderSeparation;
73+
exports.importOrderSortSpecifiers = importOrderSortSpecifiers;

.template-lintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

33
module.exports = {
4-
plugins: ['ember-template-lint-plugin-prettier'],
5-
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
4+
extends: ['recommended'],
65
rules: {
76
'no-curly-component-invocation': {
87
allow: ['svg-jar', '-with-dynamic-vars'],

CHANGELOG.md

Lines changed: 168 additions & 100 deletions
Large diffs are not rendered by default.

RELEASE.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Releases are mostly automated using
44
[release-it](https://github.com/release-it/release-it/) and
55
[lerna-changelog](https://github.com/lerna/lerna-changelog/).
66

7-
87
## Preparation
98

109
Since the majority of the actual release process is automated, the primary
@@ -18,25 +17,24 @@ guiding principle here is that changelogs are for humans, not machines.
1817

1918
When reviewing merged PR's the labels to be used are:
2019

21-
* breaking - Used when the PR is considered a breaking change.
22-
* enhancement - Used when the PR adds a new feature or enhancement.
23-
* bug - Used when the PR fixes a bug included in a previous release.
24-
* documentation - Used when the PR adds or updates documentation.
25-
* internal - Used for internal changes that still require a mention in the
20+
- breaking - Used when the PR is considered a breaking change.
21+
- enhancement - Used when the PR adds a new feature or enhancement.
22+
- bug - Used when the PR fixes a bug included in a previous release.
23+
- documentation - Used when the PR adds or updates documentation.
24+
- internal - Used for internal changes that still require a mention in the
2625
changelog/release notes.
2726

28-
2927
## Release
3028

3129
Once the prep work is completed, the actual release is straight forward:
3230

33-
* First, ensure that you have installed your projects dependencies:
31+
- First, ensure that you have installed your projects dependencies:
3432

3533
```
3634
pnpm install
3735
```
3836

39-
* Second, ensure that you have obtained a
37+
- Second, ensure that you have obtained a
4038
[GitHub personal access token][generate-token] with the `repo` scope (no
4139
other permissions are needed). Make sure the token is available as the
4240
`GITHUB_AUTH` environment variable.
@@ -49,7 +47,7 @@ pnpm install
4947

5048
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
5149

52-
* And last (but not least 😁) do your release.
50+
- And last (but not least 😁) do your release.
5351

5452
```
5553
npx release-it

app/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import Application from '@ember/application';
22

3+
import { InitSentryForEmber } from '@sentry/ember';
34
import loadInitializers from 'ember-load-initializers';
45
import Resolver from 'ember-resolver';
56

6-
import { InitSentryForEmber } from '@sentry/ember';
7-
87
import config from 'swach/config/environment';
98

109
InitSentryForEmber();

app/authenticators/cognito.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ export default class CognitoAuthenticatorExtended extends CognitoAuthenticator {
1616

1717
async _resolveAuth(user) {
1818
const { cognito } = this;
19+
1920
cognito._setUser(user);
2021

2122
// Now pull out the (promisified) user
2223
const session = await cognito.user.getSession();
2324
const credentials = await this.auth.currentCredentials();
2425

2526
cognito.startRefreshTask(session);
27+
2628
return this._makeAuthData(user, session, credentials);
2729
}
2830

@@ -31,8 +33,10 @@ export default class CognitoAuthenticatorExtended extends CognitoAuthenticator {
3133
const { auth, user } = cognito;
3234
// Get the session, which will refresh it if necessary
3335
const session = await user.getSession();
36+
3437
if (session.isValid()) {
3538
cognito.startRefreshTask(session);
39+
3640
const awsUser = await auth.currentAuthenticatedUser();
3741
const credentials = await this.auth.currentCredentials();
3842

File renamed without changes.

app/components/about/index.ts renamed to app/components/about.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class AboutComponent extends Component<AboutSignature> {
1919

2020
if (typeof requireNode !== 'undefined') {
2121
const { ipcRenderer } = requireNode('electron');
22+
2223
this.ipcRenderer = ipcRenderer;
2324

2425
this.ipcRenderer.invoke('getAppVersion').then((version: string) => {
File renamed without changes.

app/components/alpha-input/index.ts renamed to app/components/alpha-input.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { action, set } from '@ember/object';
22
import Component from '@glimmer/component';
33

4-
import { SelectedColorModel } from 'swach/components/rgb-input';
4+
import type { SelectedColorModel } from 'swach/components/rgb-input';
55
import { rgbaToHex } from 'swach/data-models/color';
66

77
interface AlphaInputSignature {
@@ -27,6 +27,7 @@ export default class AlphaInputComponent extends Component<AlphaInputSignature>
2727
@action
2828
isComplete(buffer: Buffer, opts: { regex: string }): boolean {
2929
const value = buffer.join('');
30+
3031
return Boolean(value.length) && new RegExp(opts.regex).test(value);
3132
}
3233

@@ -48,6 +49,7 @@ export default class AlphaInputComponent extends Component<AlphaInputSignature>
4849

4950
const { r, g, b, a } = selectedColor;
5051
const hex = rgbaToHex(r, g, b, a);
52+
5153
set(selectedColor, '_hex', hex);
5254
set(selectedColor, 'hex', hex);
5355
this.args.updateColor();

app/components/animated-drag-sort-list/index.ts renamed to app/components/animated-drag-sort-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class AnimatedDragSortList extends DragSortList {
3838
if (sprite.finalBounds?.height) {
3939
sprite.startTranslatedBy(0, -sprite.finalBounds.height / 2);
4040
}
41+
4142
move(sprite, { easing: easeOut });
4243
}
4344

app/components/color-picker/index.hbs renamed to app/components/color-picker.hbs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{#if @isShown}}
2+
{{!@glint-expect-error ember-tooltips does not ship types}}
23
<EmberPopover
34
@arrowClass="color-picker-arrow custom-arrow"
45
@event="none"
@@ -8,11 +9,7 @@
89
@spacing={{10}}
910
@tooltipClass="color-picker-popover bg-main border-menu fixed h-full m-0 pb-4 pl-3 pr-3 pt-5 text-alt w-screen"
1011
>
11-
<div
12-
class="h-full relative w-full"
13-
data-test-color-picker
14-
{{did-update this.setScrollPosition}}
15-
>
12+
<div class="h-full relative w-full" data-test-color-picker>
1613
<ColorRow @color={{this._selectedColor}} @showActions={{false}} />
1714

1815
<div class="bg-menu flex p-4 relative rounded">

app/components/color-picker/index.ts renamed to app/components/color-picker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import type { Store } from 'ember-orbit';
99
import { TinyColor } from '@ctrl/tinycolor';
1010
import iro from '@jaames/iro';
1111

12-
import {
12+
import 'swach/components/color-row';
13+
import type {
1314
PrivateRGBAHex,
1415
PublicRGBAHex,
1516
SelectedColorModel,
1617
SelectedColorPOJO,
1718
} from 'swach/components/rgb-input';
18-
import ColorModel, { rgbaToHex } from 'swach/data-models/color';
19+
import { rgbaToHex } from 'swach/data-models/color';
20+
import type ColorModel from 'swach/data-models/color';
1921
import type NearestColor from 'swach/services/nearest-color';
2022
import type UndoManager from 'swach/services/undo-manager';
2123

@@ -47,6 +49,7 @@ export default class ColorPickerComponent extends Component<ColorPickerSignature
4749

4850
if (this._selectedColor?.hex) {
4951
const tinyColor = new TinyColor(this._selectedColor.hex);
52+
5053
hsl = tinyColor.toHslString();
5154
hsv = tinyColor.toHsvString();
5255
rgb = tinyColor.toRgbString();
@@ -64,13 +67,15 @@ export default class ColorPickerComponent extends Component<ColorPickerSignature
6467
};
6568

6669
const { selectedColor } = this.args;
70+
6771
this.setSelectedColor(selectedColor ? selectedColor.hex : '#42445a');
6872
this._setupColorPicker(element, this._selectedColor.hex);
6973
}
7074

7175
@action
7276
async saveColorAndClose(): Promise<void> {
7377
const colorToEdit = this.args.selectedColor;
78+
7479
// If we passed a color to edit, save it, otherwise create a new global color
7580
if (colorToEdit) {
7681
// TODO: Consider refactoring to use a single `updateRecord` operation
@@ -125,6 +130,7 @@ export default class ColorPickerComponent extends Component<ColorPickerSignature
125130
updateColor(): void {
126131
const { r, g, b } = this._selectedColor;
127132
const namedColor = this.nearestColor.nearest({ r, g, b });
133+
128134
set(this._selectedColor, 'name', namedColor.name);
129135

130136
this.colorPicker?.setColors([this._selectedColor].mapBy('hex'));
File renamed without changes.

app/components/color-row/index.ts renamed to app/components/color-row.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface ColorRowSignature {
1212
Element: HTMLDivElement;
1313
Args: {
1414
color: ColorModel;
15-
deleteColor: (color: ColorModel) => void;
15+
deleteColor?: (color: ColorModel) => void;
1616
palette: PaletteModel;
1717
showActions: boolean;
1818
toggleColorPickerIsShown: (color?: ColorModel) => void;
@@ -34,7 +34,7 @@ export default class ColorRowComponent extends Component<ColorRowSignature> {
3434
@action
3535
deleteColor(color: ColorModel): void {
3636
if (!this.args.palette.isLocked) {
37-
this.args.deleteColor(color);
37+
this.args.deleteColor?.(color);
3838
}
3939
}
4040

File renamed without changes.

app/components/colors-list/index.ts renamed to app/components/colors-list.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { action } from '@ember/object';
22
import { service } from '@ember/service';
33
import Component from '@glimmer/component';
44

5-
import Sprite from 'ember-animated/-private/sprite';
5+
import type Sprite from 'ember-animated/-private/sprite';
66
import { easeOut } from 'ember-animated/easings/cosine';
77
import move from 'ember-animated/motions/move';
88
import { fadeOut } from 'ember-animated/motions/opacity';
99
import type { Store } from 'ember-orbit';
1010

1111
import type { RecordOperationTerm } from '@orbit/records';
1212

13+
import 'swach/components/color-row';
1314
import type ColorModel from 'swach/data-models/color';
1415
import type PaletteModel from 'swach/data-models/palette';
1516
import type UndoManager from 'swach/services/undo-manager';
@@ -27,6 +28,7 @@ export default class ColorsListComponent extends Component<ColorsListSignature>
2728

2829
get sortedColors(): (ColorModel | undefined)[] | undefined {
2930
const { palette } = this.args;
31+
3032
if (!palette.$isDisconnected) {
3133
if (palette.isColorHistory) {
3234
return palette.colors.sortBy('createdAt').reverse();
@@ -36,6 +38,8 @@ export default class ColorsListComponent extends Component<ColorsListSignature>
3638
});
3739
}
3840
}
41+
42+
return undefined;
3943
}
4044

4145
*transition({
@@ -51,6 +55,7 @@ export default class ColorsListComponent extends Component<ColorsListSignature>
5155
if (sprite.finalBounds?.height) {
5256
sprite.startTranslatedBy(0, -sprite.finalBounds.height / 2);
5357
}
58+
5459
move(sprite, { easing: easeOut });
5560
}
5661

@@ -66,6 +71,7 @@ export default class ColorsListComponent extends Component<ColorsListSignature>
6671
@action
6772
async deleteColor(color: ColorModel): Promise<void> {
6873
const { palette } = this.args;
74+
6975
if (color && palette && !palette.isLocked) {
7076
const colorsList = palette.colors.map((color) => {
7177
return { type: 'color', id: color.id };

0 commit comments

Comments
 (0)