Skip to content

Commit a7caee2

Browse files
authored
Merge pull request #2 from alevnyacow/feature/package-base
package base with github ci/cd
2 parents 97da59c + 800cdfd commit a7caee2

File tree

11 files changed

+176
-0
lines changed

11 files changed

+176
-0
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules/**
2+
/tests/**
3+
/transpiled/**

.eslintrc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"parserOptions": {
6+
"ecmaVersion": 2017,
7+
"sourceType": "module"
8+
},
9+
"rules": {
10+
// ban debug stuff
11+
"no-console": "error",
12+
"no-debugger": "error",
13+
// function writing rules
14+
"max-params": ["error", 3],
15+
"max-depth": ["error", 3],
16+
"no-unreachable": "error",
17+
"no-else-return": "error",
18+
"no-var": "error",
19+
"one-var": ["error", "never"],
20+
"init-declarations": ["error", "always"],
21+
// namings
22+
"camelcase": "error",
23+
"id-length": [
24+
"error",
25+
// "x" is for anonymous lambdas, "i" is for iterators in "for" loops
26+
{ "min": 3, "max": 40, "exceptions": ["x", "i", "id"] }
27+
],
28+
// common code style
29+
"curly": "error",
30+
"prefer-const": "error",
31+
"no-redeclare": "error",
32+
"prefer-destructuring": [
33+
"error",
34+
{ "object": true, "array": false },
35+
{ "enforceForRenamedProperties": false }
36+
],
37+
"eqeqeq": "error",
38+
"default-case": "error",
39+
"no-magic-numbers": "off",
40+
"@typescript-eslint/no-magic-numbers": ["error", { "ignoreArrayIndexes": true, "ignoreEnums": true, "ignore": [0, 1, -1] }],
41+
"no-unused-expressions": "error",
42+
"@typescript-eslint/no-unused-vars": "error",
43+
"no-nested-ternary": "error",
44+
"no-empty": "error",
45+
"for-direction": "error",
46+
"no-sparse-arrays": "error",
47+
"yoda": "error"
48+
}
49+
}

.github/workflows/npm-publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
run-tests-and-linter:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 16
18+
- run: npm i
19+
- run: npm run check
20+
21+
publish-to-npm:
22+
needs: run-tests-and-linter
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions/setup-node@v2
27+
with:
28+
node-version: 16
29+
registry-url: https://registry.npmjs.org/
30+
- run: npm i
31+
- run: npm run build
32+
- run: npm publish --access public
33+
env:
34+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
package-lock.json
3+
transpiled

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
sources
3+
tests

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"tabWidth": 4,
3+
"trailingComma": "none",
4+
"semi": true,
5+
"printWidth": 80,
6+
"singleQuote": false,
7+
"arrowParens": "always",
8+
"bracketSpacing": true,
9+
"parser": "typescript",
10+
"useTabs": false
11+
}

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
preset: 'ts-jest'
3+
}

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "@alevnyacow/shared-react-variables",
3+
"version": "0.0.1",
4+
"description": "Easy and comfortable React state manager",
5+
"main": "transpiled/index.js",
6+
"scripts": {
7+
"test": "jest",
8+
"clean_transpiled": "del-cli --force ./transpiled",
9+
"format": "prettier --config .prettierrc --write sources/**",
10+
"lint": "eslint sources/**/*.ts --ext .ts",
11+
"check": "npm run lint && npm run test",
12+
"build": "npm run clean_transpiled && tsc",
13+
"execute": "npm run build && node transpiled/index.js"
14+
},
15+
"keywords": [
16+
"react",
17+
"state",
18+
"state management",
19+
"global state"
20+
],
21+
"author": "alevnyacow",
22+
"license": "MIT",
23+
"devDependencies": {
24+
"@testing-library/react": "^12.1.3",
25+
"@types/jest": "^27.4.1",
26+
"@types/react": "^17.0.39",
27+
"@typescript-eslint/eslint-plugin": "^5.14.0",
28+
"@typescript-eslint/parser": "^5.14.0",
29+
"del-cli": "^4.0.1",
30+
"eslint": "^8.10.0",
31+
"jest": "^27.5.1",
32+
"prettier": "^2.5.1",
33+
"react": "^17.0.2",
34+
"ts-jest": "^27.1.3",
35+
"typescript": "^4.6.2"
36+
},
37+
"types": "transpiled/index.d.ts",
38+
"dependencies": {
39+
"@alevnyacow/deep-js-proxy": "^0.0.1"
40+
},
41+
"repository": {
42+
"type": "git",
43+
"url": "git+https://github.com/alevnyacow/shared-react-variables.git"
44+
},
45+
"bugs": {
46+
"url": "https://github.com/alevnyacow/shared-react-variables/issues"
47+
},
48+
"homepage": "https://github.com/alevnyacow/shared-react-variables#readme"
49+
}

sources/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const answerForEverything = 42;
2+
3+
export { answerForEverything };

tests/dummy.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test("dummy_test", () => {
2+
expect(1).toBe(1);
3+
});

0 commit comments

Comments
 (0)