Skip to content

Commit fa09ebe

Browse files
author
Jakub Sowinski
committed
Added linters, reorganized configuration
1 parent 9ae4060 commit fa09ebe

10 files changed

+75
-47
lines changed

README.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,40 @@ Run
88
npm install
99
```
1010
Your app is now installed and ready to go.
11+
1112
#### Build
1213
Run
1314
```
1415
npm run build
1516
```
1617
Result of your build will be in ``build`` directory.
18+
1719
#### Live server
1820
Run
1921
```
2022
npm start
2123
```
2224
Your live server is available at ``http://localhost:3000/``.
25+
2326
#### Tests
2427
Run
2528
```
2629
npm run test
2730
```
2831
Tests report will be displayed in console.
2932

33+
#### Linting
34+
In order to run general linter, use
35+
```
36+
npm run lint
37+
```
38+
In order to run specific linters, use
39+
```
40+
npm run lint:ts
41+
npm run lint:css
42+
```
43+
Linters report will be displayed in console.
44+
3045
## Changelist:
3146
#### v.0.1
3247
##### v0.1.1
@@ -48,13 +63,19 @@ Tests report will be displayed in console.
4863
* React-Bootstrap
4964
* SCSS processing
5065

51-
#### to be added
52-
* SCSSLint
66+
##### v0.1.3
67+
* Awesome TypeScript Loader
5368
* TSLint
54-
* JSX-Loader
69+
* SCSSLint
70+
* basic linting rules
71+
72+
#### to be added
5573
* Express
5674
* IE9 support
75+
* absolute import
5776
* sophisticated HMR
77+
* sophisticated linting rules
78+
* source maps
5879

5980
#### to be considered
6081
* Redux-Form

app/containers/Home/style.scss

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.entry {
2-
h1, small, p {
2+
h1,
3+
small,
4+
p {
35
color: blue;
46
}
5-
}
7+
}

config/jestconfig.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"transform": {
3+
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
4+
},
5+
"testRegex": "tests/.*\\.test\\.(ts|tsx|js)$",
6+
"moduleFileExtensions": [
7+
"ts",
8+
"tsx",
9+
"js"
10+
]
11+
}

config/stylelint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: "stylelint-config-standard"
3+
};
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es5",
44
"module": "commonjs",
55
"moduleResolution": "node",
66
"allowSyntheticDefaultImports": true,
77
"sourceMap": true,
88
"jsx": "react"
99
},
10+
"include": [
11+
"app/**/*"
12+
],
1013
"exclude": [
11-
"node_modules"
14+
"node_modules",
15+
"**/*.test.ts*"
1216
]
1317
}

config/tslintconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["tslint:recommended", "tslint-eslint-rules", "tslint-react"]
3+
}

config/webpack.base.config.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
2-
3-
module.exports = {
4-
// ...
5-
module: {
6-
loaders: [
7-
// ...
8-
9-
]
10-
},
11-
12-
}
13-
141
var ExtractTextPlugin = require('extract-text-webpack-plugin');
152
var path = require('path');
163

@@ -29,10 +16,9 @@ module.exports = {
2916
'node_modules'
3017
],
3118
extensions: [
32-
'.js',
33-
'.jsx',
3419
'.ts',
35-
'.tsx'
20+
'.tsx',
21+
'.js'
3622
]
3723
},
3824
module: {
@@ -42,7 +28,7 @@ module.exports = {
4228
exclude: /node_modules/,
4329
loaders: [
4430
'babel-loader',
45-
'ts-loader'
31+
'awesome-typescript-loader?configFileName=config/tsconfig.json'
4632
]
4733
},
4834
{

config/webpack.dev.config.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
var webpack = require('webpack');
2-
var baseConfig = require('./webpack.base.config');
3-
var config = baseConfig;
2+
var config = require('./webpack.base.config');
43

54
config.entry = [
65
'react-hot-loader/patch',
76
'webpack-dev-server/client?http://localhost:3000',
87
'webpack/hot/only-dev-server',
9-
...baseConfig.entry || []
8+
...config.entry || []
109
];
1110

12-
config.module.loaders = baseConfig.module.loaders.map(function(loader) {
11+
config.module.loaders = config.module.loaders.map(function(loader) {
1312
if (loader.test === /\.tsx?$/) {
1413
loader.loaders = [
1514
'react-hot-loader/webpack',
@@ -21,7 +20,7 @@ config.module.loaders = baseConfig.module.loaders.map(function(loader) {
2120

2221
config.plugins = [
2322
new webpack.HotModuleReplacementPlugin(),
24-
...baseConfig.plugins || []
23+
...config.plugins || []
2524
];
2625

2726
module.exports = config;

package.json

+14-15
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
"author": "soofka",
1313
"license": "UNLICENSED",
1414
"scripts": {
15-
"build": "webpack --config ./config/webpack.prod.config.js --color -p",
16-
"start": "node scripts/server.js",
17-
"test": "jest"
15+
"build": "webpack --config ./config/webpack.prod.config.js --color --optimize-minimize",
16+
"build:dev": "webpack --config ./config/webpack.dev.config.js --color",
17+
"lint": "npm run lint:ts && npm run lint:css",
18+
"lint:ts": "tslint ./app/**/*.ts* --config ./config/tslintconfig.json",
19+
"lint:css": "stylelint ./app/**/*.*css --config ./config/stylelint.config.js",
20+
"start": "node ./scripts/server.js",
21+
"test": "jest --config ./config/jestconfig.json"
1822
},
1923
"dependencies": {
2024
"immutable": "^3.8.1",
@@ -33,6 +37,7 @@
3337
"whatwg-fetch": "^2.0.2"
3438
},
3539
"devDependencies": {
40+
"@types/core-js": "^0.9.35",
3641
"@types/immutable": "^3.8.7",
3742
"@types/jest": "^18.1.1",
3843
"@types/node": "^7.0.5",
@@ -44,6 +49,7 @@
4449
"@types/redux": "^3.6.0",
4550
"@types/redux-immutable": "^3.0.33",
4651
"@types/whatwg-fetch": "0.0.33",
52+
"awesome-typescript-loader": "^3.0.7",
4753
"babel-core": "^6.22.1",
4854
"babel-jest": "^18.0.0",
4955
"babel-loader": "^6.2.10",
@@ -63,20 +69,13 @@
6369
"react-hot-loader": "^3.0.0-beta.6",
6470
"react-test-renderer": "^15.4.2",
6571
"sass-loader": "^6.0.2",
72+
"stylelint": "^7.9.0",
73+
"stylelint-config-standard": "^16.0.0",
6674
"ts-jest": "^18.0.3",
67-
"ts-loader": "^2.0.0",
75+
"tslint": "^4.4.2",
76+
"tslint-eslint-rules": "^3.4.0",
77+
"tslint-react": "^2.4.0",
6878
"webpack": "^2.2.1",
6979
"webpack-dev-server": "^2.3.0"
70-
},
71-
"jest": {
72-
"transform": {
73-
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
74-
},
75-
"testRegex": "tests/.*\\.test\\.(ts|tsx|js)$",
76-
"moduleFileExtensions": [
77-
"ts",
78-
"tsx",
79-
"js"
80-
]
8180
}
8281
}

scripts/server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
var webpack = require('webpack');
22
var webpackDevServer = require('webpack-dev-server');
3-
var devConfig = require('../config/webpack.dev.config');
3+
var config = require('../config/webpack.dev.config');
44

5-
new webpackDevServer(webpack(devConfig), {
6-
publicPath: devConfig.output.publicPath,
5+
new webpackDevServer(webpack(config), {
6+
publicPath: config.output.publicPath,
77
hot: true,
88
historyApiFallback: true
99
}).listen(3000, 'localhost', function (err) {

0 commit comments

Comments
 (0)