-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a69939
Showing
16 changed files
with
13,136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
version: "2" | ||
checks: | ||
argument-count: | ||
config: | ||
threshold: 6 | ||
complex-logic: | ||
config: | ||
threshold: 10 | ||
file-lines: | ||
config: | ||
threshold: 500 | ||
method-complexity: | ||
config: | ||
threshold: 10 | ||
method-count: | ||
config: | ||
threshold: 30 | ||
method-lines: | ||
config: | ||
threshold: 25 | ||
nested-control-flow: | ||
config: | ||
threshold: 4 | ||
return-statements: | ||
config: | ||
threshold: 4 | ||
similar-code: | ||
config: | ||
threshold: 100 | ||
identical-code: | ||
config: | ||
threshold: 75 | ||
plugins: | ||
fixme: | ||
enabled: true | ||
config: | ||
strings: | ||
- FIXME | ||
- XXX | ||
- BUG | ||
- TODO | ||
git-legal: | ||
enabled: true | ||
nodesecurity: | ||
enabled: true | ||
|
||
exclude_patterns: | ||
- "**/dist/" | ||
- "**/node_modules/" | ||
- "**/test/" | ||
- "**/*.d.ts" | ||
- ".mailmap" | ||
- "**/*.md" | ||
- "**/*polyfill*" | ||
- "*conf*" | ||
- "**/_*" | ||
- "example/" | ||
- "gulpfile*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/eslintrc", | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"env": { | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"rules": { | ||
"no-console": "error", | ||
"no-debugger": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-inferrable-types": "off" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["**/test/**/*.test.{j,t}s?(x)"], | ||
"env": { "jest": true, "node": true }, | ||
"rules": { | ||
"@typescript-eslint/ban-ts-comment": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["example/**/*"], | ||
"rules": { | ||
"no-console": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/ban-ts-comment": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
# Operating Systems | ||
.DS_Store | ||
**/Thumbs.db | ||
|
||
# NPM | ||
node_modules | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Build Targets | ||
/dist | ||
|
||
# Local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Jest test coverage | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/prettierrc", | ||
"printWidth": 100, | ||
"endOfLine": "lf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
os: linux | ||
language: node_js | ||
cache: npm | ||
|
||
jobs: | ||
include: | ||
- stage: release | ||
node_js: lts/* | ||
# before_script: | ||
# - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
# - chmod +x ./cc-test-reporter | ||
# - ./cc-test-reporter before-build | ||
script: | ||
- npm install | ||
- npm run build | ||
- npm run lint | ||
# after_script: | ||
# - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT | ||
deploy: | ||
provider: script | ||
cleanup: false | ||
skip_cleanup: true | ||
script: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/cfc752577cf502adf125/maintainability)](https://codeclimate.com/github/propero-oss/easy-store/maintainability) | ||
|
||
# easy-store | ||
React bindings for [@propero/easy-store](https://github.com/propero-oss/easy-store). | ||
|
||
npm i @propero/easy-store-react | ||
|
||
## Getting started | ||
Using a store in a functional component: | ||
|
||
```typescript jsx | ||
import { createStore } from "@propero/easy-store"; | ||
import { useStore } from "@propero/easy-store-react"; | ||
|
||
const countStore = createStore(0); | ||
|
||
// Every instance of counter will now use the same count value | ||
export function Counter() { | ||
const [count, setCount, updateCount] = useStore(countStore); | ||
|
||
const increment = () => updateCount(count => count + 1); | ||
const decrement = () => updateCount(count => count - 1); | ||
|
||
return ( | ||
<> | ||
<button type="button" onClick={decrement}>-</button> | ||
<span>{count}</span> | ||
<button type="button" onClick={increment}>+</button> | ||
</> | ||
); | ||
} | ||
|
||
export function MultipleCounters() { | ||
return ( | ||
<> | ||
<Counter /> | ||
<Counter /> | ||
</> | ||
); | ||
} | ||
``` | ||
|
||
Using a subscribable: | ||
|
||
```typescript jsx | ||
import { createSubscribable } from "@propero/easy-store"; | ||
import { useSubscribable } from "src/use-subscribable"; | ||
|
||
const clickEvents = createSubscribable<[MouseEvent]>(); | ||
window.addEventListener("click", clickEvents.notify); | ||
|
||
export function Popover({ target, open: initialOpen = false, children }: { target: HTMLElement; open?: boolean; children?: any }) { | ||
const [open, setOpen] = useState(open); | ||
|
||
function onMouseClick(ev: MouseEvent) { | ||
setOpen(target === ev.target || target.contains(ev.target)); | ||
} | ||
|
||
useSubscribable(clickEvents, onMouseClick); | ||
|
||
return ( | ||
<div className="popover" style={{display: open ? "block" : "none"}}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const tsconfig = require("./tsconfig.json"); | ||
const { escapeRegExp, entries, fromPairs } = require("lodash"); | ||
const { paths } = tsconfig.compilerOptions; | ||
|
||
const keyToRegexp = (key) => `^${escapeRegExp(key).replace("\\*", "(.*)")}$`; | ||
const valueToPathMatcher = ([value]) => value.replace("*", "$1").replace("./", "<rootDir>/"); | ||
const entryMapper = ([key, value]) => [keyToRegexp(key), valueToPathMatcher(value)]; | ||
const moduleNameMapper = fromPairs(entries(paths).map(entryMapper)); | ||
|
||
module.exports = { | ||
preset: "jest-preset-typescript", | ||
collectCoverage: true, | ||
collectCoverageFrom: ["src/**/*.ts", "!**/node_modules/**"], | ||
coverageReporters: ["lcovonly"], | ||
moduleNameMapper, | ||
}; |
Oops, something went wrong.