Skip to content

Commit

Permalink
(chore) - Update deps and consistent files (#239)
Browse files Browse the repository at this point in the history
* update deps

* remove git add

* run prettier

* run prettier

* update lockfile

* try reorder

* add prettierignore

* reduce logs in CI output
  • Loading branch information
JoviDeCroock authored Dec 11, 2020
1 parent 8140959 commit 6f3b3a1
Show file tree
Hide file tree
Showing 71 changed files with 2,784 additions and 2,803 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
test/fixture
temp
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ This project uses [changesets](https://github.com/atlassian/changesets). This me
every PR there must be documentation for what has been changed and which package is affected.

You can document a change by running `yarn changeset` in the root, which will ask you which packages
have changed and whether the change is major/minor/patch. It will then ask you to write a change entry as markdown.
have changed and whether the change is major/minor/patch. It will then ask you to write a change entry as markdown.

[Read more about adding a `changeset` here.](https://github.com/atlassian/changesets/blob/master/docs/adding-a-changeset.md#i-am-in-a-multi-package-repository-a-mono-repo)
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ Do note that a component as seen below is not named.

```jsx
export default () => {
return <p>Want to refresh</p>
}
return <p>Want to refresh</p>;
};
```

Instead do:

```jsx
const Refresh = () => {
return <p>Want to refresh</p>
}
return <p>Want to refresh</p>;
};

export default Refresh;
```

When you are working with HOC's be sure to lift up the `displayName` so we can
recognise it as a component.

12 changes: 6 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
testPathIgnorePatterns: ['/node_modules/', '/packages/'],
watchPathIgnorePatterns: ['<rootDir>/temp'],
moduleNameMapper: {
'@prefresh/core': '<rootDir>/packages/core',
'@prefresh/utils': '<rootDir>/packages/utils'
}
testPathIgnorePatterns: ['/node_modules/', '/packages/'],
watchPathIgnorePatterns: ['<rootDir>/temp'],
moduleNameMapper: {
'@prefresh/core': '<rootDir>/packages/core',
'@prefresh/utils': '<rootDir>/packages/utils',
},
};
33 changes: 15 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@
"url": "https://github.com/JoviDeCroock/prefresh/issues"
},
"authors": [
"Jovi De Croock <decroockjovi@gmail.com>"
"Jovi De Croock <jovi@preact.dev>"
],
"homepage": "https://github.com/JoviDeCroock/prefresh#readme",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"@changesets/changelog-github": "^0.2.6",
"@changesets/cli": "^2.8.0",
"eslint": "5.15.1",
"eslint-config-developit": "^1.1.1",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-react": "7.12.4",
"@changesets/changelog-github": "^0.2.7",
"@changesets/cli": "^2.12.0",
"eslint": "7.15.0",
"eslint-config-developit": "^1.2.0",
"eslint-config-prettier": "^7.0.0",
"fs-extra": "^9.0.1",
"husky": "^3.0.9",
"jest": "^26.4.2",
"lint-staged": "^9.4.2",
"prettier": "^1.18.2",
"puppeteer": "^5.2.1",
"yarn-deduplicate": "^2.0.0"
"husky": "^4.3.5",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"puppeteer": "^5.5.0",
"yarn-deduplicate": "^3.1.0"
},
"eslintConfig": {
"extends": [
Expand All @@ -57,14 +56,12 @@
],
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"useTabs": true,
"tabWidth": 2
"arrowParens": "avoid",
"trailingComma": "es5"
},
"lint-staged": {
"**/*.{js,ts}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"husky": {
Expand Down
58 changes: 29 additions & 29 deletions packages/babel/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "@prefresh/babel-plugin",
"version": "0.3.0",
"main": "dist/src/index.js",
"module": "src/index.mjs",
"exports": {
".": {
"import": "./src/index.mjs",
"require": "./dist/src/index.js"
},
"./package.json": "./package.json",
"./": "./"
},
"scripts": {
"build": "cjyes src/index.mjs",
"lint": "eslint src"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JoviDeCroock/prefresh.git",
"directory": "packages/babel"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/JoviDeCroock/prefresh/issues"
},
"homepage": "https://github.com/JoviDeCroock/prefresh#readme",
"devDependencies": {
"cjyes": "0.3.1"
}
"name": "@prefresh/babel-plugin",
"version": "0.3.0",
"main": "dist/src/index.js",
"module": "src/index.mjs",
"exports": {
".": {
"import": "./src/index.mjs",
"require": "./dist/src/index.js"
},
"./package.json": "./package.json",
"./": "./"
},
"scripts": {
"build": "cjyes src/index.mjs",
"lint": "eslint src"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JoviDeCroock/prefresh.git",
"directory": "packages/babel"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/JoviDeCroock/prefresh/issues"
},
"homepage": "https://github.com/JoviDeCroock/prefresh#readme",
"devDependencies": {
"cjyes": "0.3.1"
}
}
50 changes: 28 additions & 22 deletions packages/babel/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default function (babel, opts = {}) {
if (env !== 'development' && !opts.skipEnvCheck) {
throw new Error(
'Prefresh Babel transform should only be enabled in development environment. ' +
'Instead, the environment is: "' +
env +
'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.'
'Instead, the environment is: "' +
env +
'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.'
);
}
}
Expand All @@ -39,7 +39,7 @@ export default function (babel, opts = {}) {
const registrations = registrationsByProgramPath.get(programPath);
registrations.push({
handle,
persistentID
persistentID,
});

return handle;
Expand Down Expand Up @@ -253,7 +253,7 @@ export default function (babel, opts = {}) {
key: fnHookCalls.map(call => call.name + '{' + call.key + '}').join('\n'),
customHooks: fnHookCalls
.filter(call => !isBuiltinHook(call.name))
.map(call => t.cloneDeep(call.callee))
.map(call => t.cloneDeep(call.callee)),
};
}

Expand Down Expand Up @@ -333,7 +333,7 @@ export default function (babel, opts = {}) {
null,
[],
t.blockStatement([
t.returnStatement(t.arrayExpression(customHooksInScope))
t.returnStatement(t.arrayExpression(customHooksInScope)),
])
)
);
Expand Down Expand Up @@ -391,18 +391,24 @@ export default function (babel, opts = {}) {
} else if (name === 'useReducer' && args.length > 1) {
// useReducer second argument is initial state.
key += '(' + args[1].getSource() + ')';
} else if ((name === 'useEffect' || name === 'useLayoutEffect') && args.length > 1) {
} else if (
(name === 'useEffect' || name === 'useLayoutEffect') &&
args.length > 1
) {
key += '(' + args[0].getSource() + ')';
} else if ((name === 'useCallback' || name === 'useMemo') && args.length > 1) {
} else if (
(name === 'useCallback' || name === 'useMemo') &&
args.length > 1
) {
key += '(' + args[0].getSource() + ')';
}

hookCallsForFn.push({
callee: path.node.callee,
name,
key
key,
});
}
},
};

const createContextTemplate = template(
Expand Down Expand Up @@ -468,7 +474,7 @@ export default function (babel, opts = {}) {
t.assignmentExpression('=', handle, path.node.id)
)
);
}
},
},
CallExpression(path, state) {
if (!path.get('callee').referencesImport('preact', 'createContext'))
Expand All @@ -494,14 +500,14 @@ export default function (babel, opts = {}) {
createContextTemplate({
CREATECONTEXT: path.get('callee').node,
IDENT: t.identifier(id),
VALUE: t.clone(getFirstNonTsExpression(path.node.arguments[0]))
VALUE: t.clone(getFirstNonTsExpression(path.node.arguments[0])),
})
);
} else {
path.replaceWith(
emptyTemplate({
CREATECONTEXT: path.get('callee').node,
IDENT: t.identifier(id)
IDENT: t.identifier(id),
})
);
}
Expand Down Expand Up @@ -628,7 +634,7 @@ export default function (babel, opts = {}) {
const sigCallID = path.scope.generateUidIdentifier('_s');
path.scope.parent.push({
id: sigCallID,
init: t.callExpression(refreshSig, [])
init: t.callExpression(refreshSig, []),
});

// The signature call is split in two parts. One part is called inside the function.
Expand Down Expand Up @@ -669,7 +675,7 @@ export default function (babel, opts = {}) {
)
)
);
}
},
},
'ArrowFunctionExpression|FunctionExpression': {
exit(path) {
Expand All @@ -690,14 +696,14 @@ export default function (babel, opts = {}) {
const sigCallID = path.scope.generateUidIdentifier('_s');
path.scope.parent.push({
id: sigCallID,
init: t.callExpression(refreshSig, [])
init: t.callExpression(refreshSig, []),
});

// The signature call is split in two parts. One part is called inside the function.
// This is used to signal when first render happens.
if (path.node.body.type !== 'BlockStatement') {
path.node.body = t.blockStatement([
t.returnStatement(path.node.body)
t.returnStatement(path.node.body),
]);
}
path
Expand Down Expand Up @@ -749,7 +755,7 @@ export default function (babel, opts = {}) {
);
// Result: let Foo = hoc(__signature(() => {}, ...))
}
}
},
},
VariableDeclaration(path) {
const node = path.node;
Expand Down Expand Up @@ -857,14 +863,14 @@ export default function (babel, opts = {}) {
t.expressionStatement(
t.callExpression(refreshReg, [
handle,
t.stringLiteral(persistentID)
t.stringLiteral(persistentID),
])
)
);
declarators.push(t.variableDeclarator(handle));
});
}
}
}
},
},
},
};
}
Loading

0 comments on commit 6f3b3a1

Please sign in to comment.