Skip to content

Commit

Permalink
Merge pull request #736 from NullVoxPopuli/update-linting
Browse files Browse the repository at this point in the history
Update linting
  • Loading branch information
NullVoxPopuli authored Mar 3, 2023
2 parents 2d09422 + 51c0f7c commit a084d58
Show file tree
Hide file tree
Showing 30 changed files with 720 additions and 3,534 deletions.
2 changes: 1 addition & 1 deletion .github/actions/assert-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
echo '
target: ${{ env.dist }}
setup:
run: pnpm build:js
run: pnpm build
cwd: ./ember-resources
expect: |
core/index.js
Expand Down
1 change: 1 addition & 0 deletions ember-resources/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# copied from root
/README.md
/LICENSE.md

# output
dist/
Expand Down
22 changes: 22 additions & 0 deletions ember-resources/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/
CHANGELOG.md

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
30 changes: 30 additions & 0 deletions ember-resources/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

module.exports = {
plugins: ['prettier-plugin-ember-template-tag'],
printWidth: 100,
singleQuote: true,
templateSingleQuote: false,
// this was required to make the VSCode + Prettier work correctly with <template>, see https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/38
// we should roll this back once that issue has been fixed!
overrides: [
{
files: '*.hbs',
options: {
singleQuote: false,
},
},
{
files: '*.gjs',
options: {
parser: 'ember-template-tag',
},
},
{
files: '*.gts',
options: {
parser: 'ember-template-tag',
},
},
],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
extends: 'octane',
extends: 'recommended',
};
28 changes: 16 additions & 12 deletions ember-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
"README.md"
],
"scripts": {
"start": "rollup -c ./config/rollup.config.mjs --watch",
"build": "FORCE_COLOR=1 npm-run-all --aggregate-output --parallel \"build:*\"",
"build:js": "rollup -c ./config/rollup.config.mjs",
"build:docs": "cp ../README.md ./README.md",
"lint": "FORCE_COLOR=1 npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "FORCE_COLOR=1 npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint . --config ./config/.template-lintrc.js",
"lint:hbs:fix": "pnpm run lint:hbs --fix",
"start": "rollup -c ./rollup.config.mjs --watch",
"build": "rollup -c ./rollup.config.mjs",
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
"lint:js": "eslint . --cache",
"lint:prettier": "prettier --check .",
"lint:prettier:fix": "prettier --write .",
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
"lint:js:fix": "eslint . --fix",
"test": "echo 'Addon does not have tests, run tests in test-app'",
"prepublishOnly": "pnpm run build",
Expand Down Expand Up @@ -116,6 +116,7 @@
},
"devDependencies": {
"@babel/core": "7.21.0",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.21.0",
"@babel/plugin-syntax-decorators": "7.21.0",
Expand All @@ -136,15 +137,18 @@
"@types/ember__object": "^4.0.2",
"@types/ember__owner": "^4.0.0",
"@types/ember__runloop": "^4.0.1",
"babel-eslint": "10.1.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"concurrently": "^7.6.0",
"ember-async-data": "^0.7.0",
"ember-template-lint": "3.16.0",
"ember-source": "4.11.0",
"eslint": "^7.32.0",
"ember-template-lint": "5.6.0",
"eslint": "^8.35.0",
"expect-type": "^0.15.0",
"npm-run-all": "4.1.5",
"prettier": "^2.8.4",
"prettier-plugin-ember-template-tag": "^0.3.2",
"rollup": "3.18.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-ts": "^3.0.0",
"tslib": "^2.4.0",
"typescript": "~4.9.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-nocheck
import ts from 'rollup-plugin-ts';
import { Addon } from '@embroider/addon-dev/rollup';
import copy from 'rollup-plugin-copy';
import { defineConfig } from 'rollup';

const addon = new Addon({
Expand Down Expand Up @@ -77,5 +78,13 @@ export default defineConfig({

// Start with a clean output directory before building
addon.clean(),

// Copy Readme and License into published package
copy({
targets: [
{ src: '../README.md', dest: '.' },
{ src: '../LICENSE.md', dest: '.' },
],
}),
],
});
63 changes: 30 additions & 33 deletions ember-resources/src/core/function-based/immediate-invocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ResourceInvokerManager {
return invokeHelper(cache, resource);
});


return { fn, args, cache, _: getValue(cache) };
}

Expand Down Expand Up @@ -138,23 +137,23 @@ class ResourceInvokerManager {
export function resourceFactory<Value = unknown, Args extends unknown[] = unknown[]>(
wrapperFn: (...args: Args) => ReturnType<typeof resource<Value>>
/**
* This is a bonkers return type.
* Here are the scenarios:
* const A = resourceFactory((...args) => {
* return resource(({ on }) => {
* ...
* })
* })
*
* Invocation styles need to be type-correct:
* @use a = A(() => [b, c, d])
* => single argument which is a function where the return type is the args
*
* {{#let (A b c d) as |a|}}
* {{a}}
* {{/let}}
* => args are passed directly as positional arguments
*/
* This is a bonkers return type.
* Here are the scenarios:
* const A = resourceFactory((...args) => {
* return resource(({ on }) => {
* ...
* })
* })
*
* Invocation styles need to be type-correct:
* @use a = A(() => [b, c, d])
* => single argument which is a function where the return type is the args
*
* {{#let (A b c d) as |a|}}
* {{a}}
* {{/let}}
* => args are passed directly as positional arguments
*/
) {
setHelperManager(ResourceInvokerFactory, wrapperFn);

Expand All @@ -163,27 +162,25 @@ export function resourceFactory<Value = unknown, Args extends unknown[] = unknow

type ResourceBlueprint<Value, Args> =
/**
* type for JS invocation with @use
* @use a = A.from(() => [b, c, d])
*/
* type for JS invocation with @use
* @use a = A.from(() => [b, c, d])
*/
| ((thunk: () => SpreadFor<Args>) => ReturnType<typeof resource<Value>>)
/**
* Type for template invocation
* {{#let (A b c d) as |a|}}
* {{a}}
* {{/let}}
* {{#let (A b c d) as |a|}}
* {{a}}
* {{/let}}
*/
| ((...args: SpreadFor<Args>) => ReturnType<typeof resource<Value>>)
/**
* Not passing args is allowed, too
* @use a = A.from()
*
* {{A}}
*/
| (() => ReturnType<typeof resource<Value>>)
// semicolon
;

* Not passing args is allowed, too
* @use a = A.from()
*
* {{A}}
*/
| (() => ReturnType<typeof resource<Value>>);
// semicolon

// Provide a singleton manager.
const ResourceInvokerFactory = (owner: Owner) => new ResourceInvokerManager(owner);
Loading

0 comments on commit a084d58

Please sign in to comment.