Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit 6bb60d8

Browse files
author
vladkampov
committed
first look on the basic project structure
0 parents  commit 6bb60d8

12 files changed

+5532
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["env"]
3+
}

.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.*rc
2+
node_modules/
3+
test/
4+
dist/
5+
conf/
6+
coverage/

.eslintrc

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"extends": [
3+
"eslint-config-airbnb"
4+
],
5+
"rules": {
6+
"import/extensions": ["off"],
7+
"import/first": ["error", null],
8+
"import/order": "warn",
9+
"class-methods-use-this": ["error"],
10+
"no-param-reassign": ["error", { "props": false }],
11+
"indent": ["warn", 2, {"SwitchCase": 1}],
12+
"max-len": ["warn", {
13+
"code": 110
14+
}],
15+
"comma-dangle": ["warn", {
16+
"arrays": "always-multiline",
17+
"objects": "always-multiline",
18+
"imports": "always-multiline",
19+
"exports": "always-multiline",
20+
"functions": "ignore"
21+
}],
22+
"no-shadow": "off",
23+
"no-case-declarations": "off",
24+
"no-restricted-syntax": [
25+
"error",
26+
{
27+
"selector": "ForInStatement",
28+
"message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
29+
},
30+
{
31+
"selector": "ForOfStatement",
32+
"message": "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations."
33+
},
34+
{
35+
"selector": "LabeledStatement",
36+
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
37+
},
38+
{
39+
"selector": "WithStatement",
40+
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
41+
}
42+
],
43+
"comma-spacing": ["warn", { "before": false, "after": true }],
44+
"camelcase": ["warn", { "properties": "never" }],
45+
"keyword-spacing": ["warn", {
46+
"before": true,
47+
"after": true,
48+
"overrides": {
49+
"return": { "after": true },
50+
"throw": { "after": true },
51+
"case": { "after": true }
52+
}
53+
}],
54+
"semi": ["warn", "always"],
55+
"no-underscore-dangle": ["warn", { "allowAfterThis": false }],
56+
"no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true }],
57+
"object-curly-spacing": ["warn", "always"],
58+
"quote-props": ["warn", "as-needed", { "keywords": false, "unnecessary": true, "numbers": false }],
59+
"space-before-function-paren": ["warn", {
60+
"anonymous": "always",
61+
"named": "never",
62+
"asyncArrow": "always"
63+
}],
64+
"spaced-comment": ["warn", "always", {
65+
"line": {
66+
"exceptions": ["-", "+"],
67+
"markers": ["=", "!"]
68+
},
69+
"block": {
70+
"exceptions": ["-", "+"],
71+
"markers": ["=", "!"],
72+
"balanced": true
73+
}
74+
}],
75+
"prefer-template": "warn",
76+
"prefer-const": ["warn", {
77+
"destructuring": "any",
78+
"ignoreReadBeforeAssign": true
79+
}],
80+
"prefer-arrow-callback": ["warn", {
81+
"allowNamedFunctions": false,
82+
"allowUnboundThis": true
83+
}],
84+
"arrow-parens": ["warn", "as-needed"],
85+
"no-console": ["warn", { "allow": ["warn", "error"] }],
86+
"padded-blocks": "off",
87+
"eol-last": "warn",
88+
"no-trailing-spaces": "warn",
89+
"quotes": "warn",
90+
"no-multiple-empty-lines": "warn"
91+
},
92+
"env" : {
93+
"jest": true,
94+
"node": true
95+
},
96+
"parser": "babel-eslint",
97+
"plugins": ["babel"]
98+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.log
2+
node_modules/
3+
dist/
4+
coverage/

conf/jest.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
rootDir: path.join(process.cwd(), './'),
5+
collectCoverage: true,
6+
verbose: true,
7+
};

conf/webpack.config.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const CleanWebpackPlugin = require('clean-webpack-plugin');
4+
5+
module.exports = {
6+
context: path.join(process.cwd(), 'src'), // the home directory for webpack
7+
8+
devtool: 'source-map', // enhance debugging by adding meta info for the browser devtools
9+
10+
entry: {
11+
app: './index.js',
12+
},
13+
14+
output: {
15+
path: path.join(process.cwd(), 'dist'),
16+
filename: '[name].[hash].js',
17+
publicPath: '/',
18+
sourceMapFilename: '[name].map',
19+
},
20+
21+
resolve: {
22+
extensions: ['.js'], // extensions that are used
23+
modules: [path.join(process.cwd(), 'src'), 'node_modules'], // directories where to look for modules
24+
},
25+
26+
devServer: {
27+
// publicPath: '/',
28+
// port: 9000,
29+
contentBase: path.join(process.cwd(), 'dist'), // static file location
30+
// host: 'localhost',
31+
// historyApiFallback: true, // true for index.html upon 404, object for multiple paths
32+
noInfo: false,
33+
stats: 'minimal',
34+
hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
35+
},
36+
37+
module: {
38+
rules: [{
39+
enforce: 'pre', // to check source files, not modified by other loaders (like babel-loader)
40+
test: /\.js$/,
41+
exclude: /node_modules/,
42+
loader: 'eslint-loader',
43+
}, {
44+
test: /\.js$/,
45+
exclude: /node_modules/,
46+
use: {
47+
loader: 'babel-loader',
48+
options: {
49+
presets: ['env'],
50+
},
51+
},
52+
}],
53+
},
54+
plugins: [
55+
new webpack.HotModuleReplacementPlugin(),
56+
new CleanWebpackPlugin(['dist'], { root: process.cwd() }),
57+
new webpack.optimize.CommonsChunkPlugin({
58+
name: 'vendor',
59+
}),
60+
],
61+
};

externalTestsRepo/lesson0.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import lessonn0 from '../src/lesson0';
2+
3+
describe('sum function', () => {
4+
test('sum', () => {
5+
expect(lessonn0.task0.sum(1, 2)).toBe(3);
6+
});
7+
test('sum', () => {
8+
expect(() => lessonn0.task0.sum(1, {})).toThrow();
9+
});
10+
test('sum', () => {
11+
expect(lessonn0.task0.sum(1, 'lalka')).toBe('1lalka');
12+
});
13+
test('sum', () => {
14+
expect(lessonn0.task0.sum('lalka', 'lalka')).toBe('lalkalalka');
15+
});
16+
test('sum', () => {
17+
expect(() => lessonn0.task0.sum({}, {})).toThrow();
18+
});
19+
test('sum', () => {
20+
expect(lessonn0.task0.sum('lalka', 1)).toBe('lalka1');
21+
});
22+
test('sum', () => {
23+
expect(() => lessonn0.task0.sum([], {})).toThrow();
24+
});
25+
test('sum', () => {
26+
expect(lessonn0.task0.sum(1)).toBe(1);
27+
});
28+
});

package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "gl-procamp-base",
3+
"version": "1.0.0",
4+
"description": "Base project for studying in GL Pro Canp academy",
5+
"main": "src/index.js",
6+
"author": "Vladyslav Kampov",
7+
"license": "MIT",
8+
"devDependencies": {
9+
"babel-core": "^6.26.0",
10+
"babel-eslint": "^8.0.3",
11+
"babel-jest": "^22.0.3",
12+
"babel-loader": "^7.1.2",
13+
"babel-preset-env": "^1.6.1",
14+
"clean-webpack-plugin": "^0.1.17",
15+
"eslint": "^4.13.1",
16+
"eslint-config-airbnb": "^16.1.0",
17+
"eslint-loader": "^1.9.0",
18+
"eslint-plugin-babel": "^4.1.2",
19+
"eslint-plugin-import": "^2.8.0",
20+
"eslint-plugin-jsx-a11y": "^6.0.3",
21+
"eslint-plugin-react": "^7.5.1",
22+
"jest": "^22.0.3",
23+
"path": "^0.12.7",
24+
"webpack": "^3.10.0",
25+
"webpack-dev-server": "^2.9.7"
26+
},
27+
"scripts": {
28+
"start": "webpack-dev-server --config conf/webpack.config.js",
29+
"build": "webpack --config conf/webpack.config.js --progress --profile",
30+
"lint": "eslint ./src/**.js",
31+
"coverage": "jest --coverage --config=conf/jest.config.js",
32+
"test": "jest --config=conf/jest.config.js",
33+
"test:watch": "jest --watch"
34+
}
35+
}

src/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import lesson0 from './lesson0';
2+
3+
export default {
4+
lesson0, // example lesson
5+
};

src/lesson0/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import task0 from './task0';
2+
3+
export default {
4+
task0, // example task
5+
};

src/lesson0/task0.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function sum(a, b) {
2+
return a + b;
3+
}
4+
5+
export default {
6+
sum,
7+
};

0 commit comments

Comments
 (0)