Skip to content

Commit a4b6803

Browse files
author
Andrei Arkhipov
authored
Merge pull request #2 from awibox/develop
#1: Environment for NPM package was created
2 parents f940536 + 69fbfe5 commit a4b6803

File tree

15 files changed

+7892
-0
lines changed

15 files changed

+7892
-0
lines changed

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-proposal-class-properties"
8+
]
9+
}

.eslintrc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"jasmine": true
6+
},
7+
"extends": [
8+
"airbnb-base",
9+
"plugin:react/recommended"
10+
],
11+
"overrides": [
12+
{
13+
"files": [
14+
"**/*.test.js",
15+
"**/*.test.jsx",
16+
"spec/*.js"
17+
],
18+
"env": {
19+
"jest": true
20+
}
21+
}
22+
],
23+
"parser": "babel-eslint",
24+
"rules": {
25+
"no-underscore-dangle": [
26+
"error",
27+
{
28+
"allow": [
29+
"__REDUX_DEVTOOLS_EXTENSION__"
30+
]
31+
}
32+
]
33+
},
34+
"settings": {
35+
"import/resolver": {
36+
"node": {
37+
"paths": [
38+
"src"
39+
],
40+
"extensions": [
41+
".js",
42+
".jsx",
43+
".ts",
44+
".tsx"
45+
]
46+
}
47+
},
48+
"react": {
49+
"createClass": "createReactClass",
50+
"pragma": "React",
51+
"version": "detect"
52+
},
53+
"propWrapperFunctions": [
54+
"forbidExtraProps",
55+
{
56+
"property": "freeze",
57+
"object": "Object"
58+
},
59+
{
60+
"property": "myFavoriteWrapper"
61+
}
62+
],
63+
"linkComponents": [
64+
"Hyperlink",
65+
{
66+
"name": "Link",
67+
"linkAttribute": "to"
68+
}
69+
]
70+
}
71+
}

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# compiled output
2+
/tmp
3+
/out-tsc
4+
5+
# dependencies
6+
/node_modules
7+
8+
# profiling files
9+
chrome-profiler-events.json
10+
speed-measure-plugin.json
11+
12+
# IDEs and editors
13+
/.idea
14+
.project
15+
.classpath
16+
.c9/
17+
*.launch
18+
.settings/
19+
*.sublime-workspace
20+
21+
# IDE - VSCode
22+
.vscode/*
23+
!.vscode/settings.json
24+
!.vscode/tasks.json
25+
!.vscode/launch.json
26+
!.vscode/extensions.json
27+
.history/*
28+
29+
# misc
30+
/.sass-cache
31+
/connect.lock
32+
/coverage
33+
/libpeerconnection.log
34+
npm-debug.log
35+
yarn-error.log
36+
testem.log
37+
/typings
38+
39+
# System Files
40+
.DS_Store
41+
Thumbs.db

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Andrei Arkhipov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.YourComponentName__text--2x8Bc{color:black;font-size:14px}
2+

jest-setup-tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import Enzyme, { shallow } from 'enzyme';
3+
import Adapter from 'enzyme-adapter-react-16';
4+
import { createSerializer } from 'enzyme-to-json';
5+
6+
// Set the default serializer for Jest to be the from enzyme-to-json
7+
// This produces an easier to read (for humans) serialized format.
8+
expect.addSnapshotSerializer(createSerializer({ mode: 'deep' }));
9+
10+
// React 16 Enzyme adapter
11+
Enzyme.configure({ adapter: new Adapter() });
12+
13+
// Define globals to cut down on imports in test files
14+
global.React = React;
15+
global.shallow = shallow;
16+
17+
// Use fake timers for async events
18+
jest.useFakeTimers();

package.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"name": "react-npm-package-template",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "./dist/index.js",
6+
"scripts": {
7+
"build": "webpack --mode production",
8+
"lint": "eslint --report-unused-disable-directives src",
9+
"fix": "eslint --fix --report-unused-disable-directives src",
10+
"test": "jest",
11+
"coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/awibox/react-npm-package-template.git"
16+
},
17+
"keywords": [
18+
"timeline",
19+
20+
"react-component",
21+
"npm-package"
22+
],
23+
"author": "awibox",
24+
"license": "MIT",
25+
"bugs": {
26+
"url": "https://github.com/awibox/react-npm-package-template/issues"
27+
},
28+
"homepage": "https://github.com/awibox/react-npm-package-template#readme",
29+
"devDependencies": {
30+
"@babel/core": "^7.8.3",
31+
"@babel/plugin-proposal-class-properties": "^7.8.3",
32+
"@babel/preset-env": "^7.8.3",
33+
"@babel/preset-react": "^7.8.3",
34+
"babel-core": "^7.0.0-bridge.0",
35+
"babel-eslint": "^10.0.3",
36+
"babel-loader": "8.0.6",
37+
"coveralls": "^3.0.9",
38+
"css-loader": "^3.4.2",
39+
"enzyme": "^3.11.0",
40+
"enzyme-adapter-react-16": "^1.15.2",
41+
"enzyme-to-json": "^3.4.3",
42+
"eslint": "^6.8.0",
43+
"eslint-config-airbnb-base": "^14.0.0",
44+
"eslint-plugin-import": "^2.20.0",
45+
"eslint-plugin-react": "^7.17.0",
46+
"jest": "^24.9.0",
47+
"jest-css-modules-transform": "^3.1.0",
48+
"jest-enzyme": "^7.1.2",
49+
"mini-css-extract-plugin": "^0.9.0",
50+
"node-sass": "^4.13.1",
51+
"sass-loader": "^8.0.2",
52+
"webpack": "^4.41.4",
53+
"webpack-cli": "^3.3.10"
54+
},
55+
"dependencies": {
56+
"prop-types": "^15.7.2",
57+
"react": "^16.12.0",
58+
"react-dom": "^16.12.0"
59+
},
60+
"jest": {
61+
"collectCoverageFrom": ["src/**/*.{js,jsx,mjs}", "!src/index.js"],
62+
"testEnvironment": "node",
63+
"moduleFileExtensions": [
64+
"js",
65+
"jsx"
66+
],
67+
"moduleDirectories": [
68+
"node_modules",
69+
"src"
70+
],
71+
"setupFilesAfterEnv": [
72+
"<rootDir>/node_modules/jest-enzyme/lib/index.js",
73+
"<rootDir>/jest-setup-tests.js"
74+
],
75+
"transform": {
76+
"^.+\\.js$": "babel-jest",
77+
".+\\.(css|styl|less|sass|scss)$": "<rootDir>/node_modules/jest-css-modules-transform"
78+
}
79+
}
80+
}

specs/YourComponentName.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import YourComponentName from '../src/components/YourComponentName';
4+
5+
describe('YourComponentName', () => {
6+
it('should render correctly', () => {
7+
const component = shallow(<YourComponentName />);
8+
expect(component).toMatchSnapshot();
9+
});
10+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`YourComponentName should render correctly 1`] = `
4+
<div
5+
className="text"
6+
>
7+
Hello world
8+
</div>
9+
`;

0 commit comments

Comments
 (0)