Skip to content

Commit 4937fa9

Browse files
committed
Upgrade dependencies and refactor away from pseudo-named yields
1 parent f6767a1 commit 4937fa9

27 files changed

+3907
-2163
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# misc
1313
/coverage/
14+
.eslintcache
1415

1516
# ember-try
1617
/.node_modules.ember-try/

.eslintrc.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ const nodeFiles = [
66
'.prettierrc.js',
77
'.template-lintrc.{js,ts}',
88
'ember-cli-build.{js,ts}',
9+
'index.{js,ts}',
910
'testem.{js,ts}',
1011
'blueprints/*/index.{js,ts}',
1112
'config/**/*.{js,ts}',
1213
'lib/*/index.{js,ts}',
1314
'server/**/*.{js,ts}',
15+
'tests/dummy/config/**/*.{js,ts}',
1416
];
1517

1618
const browserFiles = [
@@ -29,6 +31,9 @@ module.exports = {
2931
parserOptions: {
3032
ecmaVersion: 2018,
3133
sourceType: 'module',
34+
ecmaFeatures: {
35+
legacyDecorators: true,
36+
},
3237
project: ['./tsconfig.json', './tsconfig-node.json'],
3338
},
3439
plugins: ['@typescript-eslint', 'ember', 'prettier'],
@@ -40,8 +45,7 @@ module.exports = {
4045
'plugin:ember/recommended',
4146
'standard',
4247

43-
'prettier/@typescript-eslint',
44-
'prettier/standard',
48+
'prettier',
4549

4650
// This one should come last
4751
'plugin:prettier/recommended',
@@ -75,6 +79,7 @@ module.exports = {
7579
camelcase: 'off', // Have to keep this off for the TS equivalent to take precedence
7680
'no-console': ['error', { allow: ['debug', 'error', 'info', 'warn'] }],
7781
'no-unused-expressions': 'off',
82+
'no-use-before-define': 'off', // We need circular references
7883
'no-useless-constructor': 'off', // This rule crashes ESLint unless disabled
7984

8085
'node/no-unpublished-require': 'off', // Reenabled for non-Node files only
@@ -94,8 +99,8 @@ module.exports = {
9499
node: true,
95100
},
96101
plugins: ['node'],
102+
extends: ['plugin:node/recommended'],
97103
rules: {
98-
...require('eslint-plugin-node').configs.recommended.rules, // eslint-disable-line node/no-unpublished-require
99104
// add your custom rules and overrides for node files here
100105
'node/no-unsupported-features/es-syntax': ['error', { version: '>=12.0.0' }],
101106
},

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# misc
1212
/.sass-cache
13+
/.eslintcache
1314
/connect.lock
1415
/coverage/
1516
/libpeerconnection.log

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
/.editorconfig
1111
/.ember-cli
1212
/.env*
13+
/.eslintcache
1314
/.eslintignore
1415
/.eslintrc.js
1516
/.git/
1617
/.gitignore
18+
/.prettierignore
19+
/.prettierrc.js
1720
/.template-lintrc.js
1821
/.travis.yml
1922
/.watchmanconfig

.prettierignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# unconventional js
2+
/blueprints/*/files/
3+
/vendor/
4+
5+
# compiled output
6+
/dist/
7+
/tmp/
8+
9+
# dependencies
10+
/bower_components/
11+
/node_modules/
12+
13+
# misc
14+
/coverage/
15+
!.*
16+
.eslintcache
17+
18+
# ember-try
19+
/.node_modules.ember-try/
20+
/bower.json.ember-try
21+
/package.json.ember-try

.prettierrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
module.exports = {
24
arrowParens: 'always', // It's convenient that you don't have to add them by hand when you need to add more args or a type
35
singleQuote: true, // Enabled to align with EmberJS Prettier config

.template-lintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'recommended'
4+
extends: 'octane',
55
};

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_js:
55
# so that your addon works for all apps
66
- "10"
77

8-
dist: trusty
8+
dist: xenial
99

1010
addons:
1111
chrome: stable
@@ -46,20 +46,19 @@ jobs:
4646

4747
# we recommend new addons test the current and previous LTS
4848
# as well as latest stable release (bonus points to beta/canary)
49-
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
5049
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
50+
- env: EMBER_TRY_SCENARIO=ember-lts-3.20
5151
- env: EMBER_TRY_SCENARIO=ember-release
5252
- env: EMBER_TRY_SCENARIO=ember-beta
5353
- env: EMBER_TRY_SCENARIO=ember-canary
5454
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
5555
- env: EMBER_TRY_SCENARIO=ember-classic
56+
- env: EMBER_TRY_SCENARIO=embroider-safe
57+
- env: EMBER_TRY_SCENARIO=embroider-optimized
5658

5759
before_install:
5860
- curl -o- -L https://yarnpkg.com/install.sh | bash
5961
- export PATH=$HOME/.yarn/bin:$PATH
6062

61-
install:
62-
- yarn install --non-interactive
63-
6463
script:
6564
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
## Linting
1010

11-
* `yarn lint:hbs`
12-
* `yarn lint:js`
13-
* `yarn lint:js --fix`
11+
* `yarn lint`
12+
* `yarn lint:fix`
1413

1514
## Running tests
1615

README.md

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -318,36 +318,25 @@ If you want to render chunks of template conditionally, use this syntax:
318318

319319
```html
320320
<ElementQuery as |EQ|>
321-
<EQ.at-m>
321+
{{#if EQ.at-m}}
322322
{{! This will only be rendered when the `<ElementQuery>` component is of size `m`. }}
323-
</at.m>
323+
{{/if}}
324324

325-
<EQ.from-m>
325+
{{#if EQ.from-m}}
326326
{{! This will only be rendered when the `<ElementQuery>` component is of size `m` or larger. }}
327327
</EQ.from-m>
328328

329-
<EQ.to-m>
329+
{{#if EQ.to-m}}
330330
{{! This will only be rendered when the `<ElementQuery>` component is of size `m` or smaller. }}
331-
</EQ.to-m>
331+
{{/EQ.to-m}}
332332

333-
<EQ.from-s><EQ.to-l>
333+
{{#if (and EQ.from-s EQ.to-l)}}
334334
{{! This will only be rendered when the `<ElementQuery>` component is of size `s`, `m` or `l`. }}
335-
</EQ.to-l></EQ.from-s>
335+
{{/if}}
336336
</ElementQuery>
337337
```
338338

339-
If you want to "sprinke" your tempalte with small responsive bits, you may find it more convenient to use the `{{#if}}` syntax together with [ember-truth-helpers](https://github.com/jmurphyau/ember-truth-helpers):
340-
341-
```html
342-
<ElementQuery as |EQ EQInfo|>
343-
<SomeOtherComponent
344-
@isMedium={{eq EQInfo.size "s"}}
345-
@isMediumOrLarger={{bool EQ.from-m}}
346-
>
347-
</ElementQuery>
348-
```
349-
350-
The first yield argument `EQ` is a hash of current element query attributes. Keys are attribute names and values are truthy strings, so `{{bool EQ.from-m}}` gives you `true` when the element is of size `m` or larger, and `false` when the element is smaller than `m`.
339+
The first yield argument `EQ` is an object with current element query attributes. Keys are attribute names and values are `true`. Non-matching attributes are undefined. Thus, `{{#if EQ.from-m}}` renders only when the element is of size `m` or larger.
351340

352341
The second argument `EQInfo` is the same hash that is passed to the [onResize callback](#onresize-callback).
353342

@@ -363,15 +352,16 @@ You can pass a callback to the `onResize` argument and it will be called wheneve
363352
```js
364353
@action
365354
reportResize(info) {
366-
info.element // => current element
367-
info.width // => current element's width in px (number)
368-
info.height // => current element's height in px (number)
369-
info.ratio // => current element's aspect ratio (width/height, number)
370-
info.size // => current element's width size (string or undefined)
371-
info.sizeHeight // => current element's height size (string or undefined)
372-
info.dimension // => current dimension ('width', 'height' or 'both')
373-
info.prefix // => current prefix (string or undefined)
374-
info.attributes // => element query attributes used on the element (array of strings)
355+
info.element // => current element
356+
info.width // => current element's width in px (number)
357+
info.height // => current element's height in px (number)
358+
info.ratio // => current element's aspect ratio (width/height, number)
359+
info.size // => current element's width size (string or undefined)
360+
info.sizeHeight // => current element's height size (string or undefined)
361+
info.dimension // => current dimension ('width', 'height' or 'both')
362+
info.prefix // => current prefix (string or undefined)
363+
info.attributes // => matching element query attributes in array form: ['from-xxs', 'from-xs', ...]
364+
info.attributesRecord // => matching element query attributes in object form: {'from-xxs': true, 'from-xs': true, ...}
375365
}
376366
```
377367

@@ -458,9 +448,9 @@ You can customize height sizes into `@sizesHeight`. Make sure that height size n
458448
@sizesHeight={{hash small-height=0 medium-height=200 large-height=400}}
459449
as |EQ|
460450
>
461-
<EQ.to-small-width><EQ.from-large-height>
451+
{{#if (and EQ.to-small-width EQ.from-large-height)}}
462452
I am thin and tall.
463-
</EQ.from-large-height></EQ.to-small-width>
453+
{{/if}}
464454
</ElementQuery>
465455
```
466456

@@ -509,9 +499,9 @@ You can customize height sizes into `@sizesHeight`. Make sure that height size n
509499
@sizesHeight={{hash small-height=0 medium-height=200 large-height=400}}
510500
as |EQ|
511501
>
512-
<EQ.to-small-width><EQ.from-large-height>
502+
{{#if (and EQ.to-small-width EQ.from-large-height)}}
513503
I am thin and tall.
514-
</EQ.from-large-height></EQ.to-small-width>
504+
{{/if}}
515505
</ElementQuery>
516506
```
517507

@@ -769,17 +759,17 @@ Given breakpoints 350, 700 and 1050:
769759
@sizes=(hash small=0 medium=350 large=700 extraLarge=1050)
770760
as |EQ|
771761
>
772-
<EQ.at-small>...</EQ.at-small>
773-
<EQ.at-medium>...</EQ.at-medium>
774-
<EQ.at-large>...</EQ.at-large>
775-
<EQ.at-extraLarge>...</EQ.at-extraLarge>
762+
{{#if EQ.at-small}}...{{/if}}
763+
{{#if EQ.at-medium}}...{{/if}}
764+
{{#if EQ.at-large}}...{{/if}}
765+
{{#if EQ.at-extraLarge}}...{{/if}}
776766

777-
<EQ.from-medium>...</EQ.from-medium>
778-
<EQ.from-large>...</EQ.from-large>
779-
<EQ.to-medium>...</EQ.to-medium>
780-
<EQ.to-large>...</EQ.to-large>
767+
{{#if EQ.from-medium}}...{{/if}}
768+
{{#if EQ.from-large}}...{{/if}}
769+
{{#if EQ.to-medium}}...{{/if}}
770+
{{#if EQ.to-large}}...{{/if}}
781771

782-
<EQ.from-medium><EQ.to-large>...</EQ.to-large></EQ.from-medium>
772+
{{#if (and EQ.from-medium EQ.to-large)}}...{{/if}}
783773
</ElementQuery>
784774
```
785775

@@ -797,7 +787,7 @@ Given breakpoints 350, 700 and 1050:
797787
.my-component[from-medium][to-large] {}
798788
```
799789

800-
👆 Note how much shorter rule definitions are.
790+
👆 Note how much shorter the usage is, both in rule definitions and rule applications.
801791

802792

803793

@@ -987,19 +977,19 @@ Given breakpoints 350, 700 and 1050:
987977
@sizesHeight=(hash small-height=0 medium-height=200 large-height=400)
988978
as |EQ|
989979
>
990-
<EQ.to-small-width><EQ.from-large-height>
980+
{{#if (and EQ.to-small-width EQ.from-large-height)}}
991981
I am thin and tall.
992-
</EQ.from-large-height></EQ.to-small-width>
982+
{{/if}}
993983
</ElementQuery>
994984
```
995985

996986
When usign default sizes, this gets even shorter:
997987

998988
```html
999989
<ElementQuery @dimension="both" as |EQ|>
1000-
<EQ.to-s><EQ.from-l-height>
990+
{{#if (and EQ.to-s EQ.from-l-height)}}
1001991
I am thin and tall.
1002-
</EQ.from-l-height></EQ.to-s>
992+
{{/if}}
1003993
</ElementQuery>
1004994
```
1005995

@@ -1060,4 +1050,6 @@ Credit
10601050

10611051
Initially implemented by Andrey Mikhaylov ([lolmaus](https://github.com/lolmaus)) and [contributors](https://github.com/lolmaus/ember-element-query/graphs/contributors).
10621052

1063-
Thanks to Chad Carbert ([chadian](https://github.com/chadian)) and Isaac Lee ([ijlee2](https://github.com/ijlee2)) for feedback, ideas, brainstorming and criticism.
1053+
Thanks to Chad Carbert ([@chadian](https://github.com/chadian)) and Isaac Lee ([@ijlee2](https://github.com/ijlee2)) for feedback, ideas, brainstorming and criticism.
1054+
1055+
Sponsored by [@kaliber5](https://github.com/kaliber5), https://kaliber5.de.

0 commit comments

Comments
 (0)