Skip to content

Commit 0e32e6e

Browse files
committed
fixed lint rules
1 parent de265bb commit 0e32e6e

19 files changed

+202
-242
lines changed

.eslintrc

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,9 @@
11
{
2+
"extends": [
3+
"@fourjs/eslint-config-tn"
4+
],
25
"parser": "babel-eslint",
3-
"plugins": ["react"],
4-
"env": {
5-
"es6": true,
6-
"browser": true,
7-
"node": true
8-
},
96
"rules": {
10-
"no-console": 0,
11-
"react/display-name": 2,
12-
"react/jsx-key": 2,
13-
"react/jsx-no-comment-textnodes": 2,
14-
"react/jsx-no-duplicate-props": 2,
15-
"react/jsx-no-target-blank": 2,
16-
"react/jsx-no-undef": 2,
17-
"react/jsx-uses-react": 2,
18-
"react/jsx-uses-vars": 2,
19-
"react/no-children-prop": 2,
20-
"react/no-danger-with-children": 2,
21-
"react/no-deprecated": 2,
22-
"react/no-direct-mutation-state": 2,
23-
"react/no-find-dom-node": 2,
24-
"react/no-is-mounted": 2,
25-
"react/no-render-return-value": 2,
26-
"react/no-string-refs": 2,
27-
"react/no-unescaped-entities": 2,
28-
"react/no-unknown-property": 2,
29-
"react/no-unsafe": 0,
30-
"react/prop-types": 2,
31-
"react/react-in-jsx-scope": 2,
32-
"react/require-render-return": 2
33-
},
34-
"parserOptions": {
35-
"ecmaVersion": 7,
36-
"sourceType": "module",
37-
"ecmaFeatures": {
38-
"jsx": true
39-
}
40-
},
41-
"settings": {
42-
"react": {
43-
"pragma": "React",
44-
"version": "16.5",
45-
"flowVersion": "0.53"
46-
}
47-
},
48-
"extends": ["eslint:recommended"]
49-
}
7+
"babel/new-cap": 0
8+
}
9+
}

config/webpack.common.js

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
const webpack = require("webpack"),
2-
HtmlWebpackPlugin = require("html-webpack-plugin"),
3-
path = require("path"),
4-
MiniCssExtractPlugin = require("mini-css-extract-plugin"),
1+
const path = require('path'),
52
CopyWebpackPlugin = require('copy-webpack-plugin'),
6-
CleanWebpackPlugin = require('clean-webpack-plugin');
3+
CleanWebpackPlugin = require('clean-webpack-plugin'),
4+
HtmlWebpackPlugin = require('html-webpack-plugin'),
5+
MiniCssExtractPlugin = require('mini-css-extract-plugin'),
6+
webpack = require('webpack');
77

88
module.exports = mode => {
99
return {
1010
entry: {
11-
polyfills: "./polyfills.js",
12-
vendor: "./vendor.js",
13-
app: "./src/app.js"
11+
app: './src/app.js',
12+
polyfills: './polyfills.js',
13+
vendor: './vendor.js'
1414
},
1515

1616
resolve: {
17-
extensions: [".js", ".jsx"]
17+
extensions: ['.js', '.jsx']
1818
},
1919

2020
module: {
2121
rules: [{
22-
test: /\.(js|jsx)$/,
23-
exclude: /node_modules/,
24-
use: [{
25-
loader: "babel-loader"
26-
},
27-
{
28-
loader: "angularjs-template-loader?relativeTo:" +
29-
path.resolve(__dirname, "../src")
30-
}
31-
]
22+
test: /\.(js|jsx)$/,
23+
exclude: /node_modules/,
24+
use: [{
25+
loader: 'babel-loader'
3226
},
3327
{
34-
test: /\.html$/,
35-
use: [{
36-
loader: "html-loader",
37-
options: {
38-
minimize: true
39-
}
40-
}]
41-
},
42-
{
43-
test: /\.scss$/,
44-
use: [
45-
// fallback to style-loader in development
46-
!mode ?
47-
"style-loader" :
48-
MiniCssExtractPlugin.loader,
49-
"css-loader",
50-
"sass-loader"
51-
]
52-
},
53-
{
54-
test: /\.(eot|svg|ttf|woff|woff2)$/,
55-
use: "file-loader?name=pubic/fonts/[name].[ext]"
28+
loader: 'angularjs-template-loader?relativeTo:' +
29+
path.resolve(__dirname, '../src')
5630
}
31+
]
32+
},
33+
{
34+
test: /\.html$/,
35+
use: [{
36+
loader: 'html-loader',
37+
options: {
38+
minimize: true
39+
}
40+
}]
41+
},
42+
{
43+
test: /\.scss$/,
44+
use: [
45+
// fallback to style-loader in development
46+
!mode ?
47+
'style-loader' :
48+
MiniCssExtractPlugin.loader,
49+
'css-loader',
50+
'sass-loader'
51+
]
52+
},
53+
{
54+
test: /\.(eot|svg|ttf|woff|woff2)$/,
55+
use: 'file-loader?name=pubic/fonts/[name].[ext]'
56+
}
5757
]
5858
},
5959

@@ -62,24 +62,24 @@ module.exports = mode => {
6262
cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, '../dist')]
6363
}),
6464
new HtmlWebpackPlugin({
65-
template: "./index.html", // Input FileName
66-
filename: "./index.html" // Output FileName
65+
template: './index.html', // Input FileName
66+
filename: './index.html' // Output FileName
6767
}),
6868
new webpack.ProvidePlugin({}),
6969
new MiniCssExtractPlugin({
70-
filename: "[name].css"
70+
filename: '[name].css'
7171
}),
7272
new CopyWebpackPlugin(
7373
[{
74-
from: path.resolve(__dirname, "../src/partialViews/**/*.html"),
75-
to: ""
74+
from: path.resolve(__dirname, '../src/partialViews/**/*.html'),
75+
to: ''
7676
}], {}
7777
)
7878
],
7979

8080
optimization: {
8181
splitChunks: {
82-
chunks: "all",
82+
chunks: 'all',
8383
maxAsyncRequests: 5,
8484
minChunks: 1
8585
},
@@ -89,5 +89,5 @@ module.exports = mode => {
8989
stats: {
9090
warnings: false
9191
}
92-
}
93-
};
92+
};
93+
};

config/webpack.dev.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
const webpackMerge = require("webpack-merge"),
2-
commonConfig = require("./webpack.common.js"),
3-
path = require("path"),
4-
rootDir = path.resolve(__dirname, ".."),
5-
port = require("../config.json").port;
1+
const path = require('path'),
2+
webpackMerge = require('webpack-merge'),
3+
port = require('../config.json').port,
4+
commonConfig = require('./webpack.common.js'),
5+
rootDir = path.resolve(__dirname, '..');
66

77
module.exports = (mode) => {
88
return webpackMerge(commonConfig(mode), {
9-
devtool: "cheap-module-eval-source-map",
10-
mode: "development",
9+
devtool: 'cheap-module-eval-source-map',
10+
mode: 'development',
1111

1212
output: {
13-
path: path.resolve(rootDir, "dist"),
13+
path: path.resolve(rootDir, 'dist'),
1414
publicPath: `http://localhost:${port}/`,
15-
filename: "[name].js",
16-
chunkFilename: "[name].chunk.js"
15+
filename: '[name].js',
16+
chunkFilename: '[name].chunk.js'
1717
},
1818

1919
devServer: {
2020
inline: true,
21-
port: port,
21+
port,
2222
historyApiFallback: true,
23-
stats: "minimal"
23+
stats: 'minimal'
2424
}
2525
});
26-
}
26+
};

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module.exports = {
120120
// setupFiles: [],
121121

122122
// The path to a module that runs some code to configure or set up the testing framework before each test
123-
setupTestFrameworkScriptFile: "<rootDir>src/test.init.js",
123+
setupFilesAfterEnv: ["<rootDir>src/test.init.js"],
124124

125125
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
126126
// snapshotSerializers: [],

src/about/aboutComp/aboutComponent.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
aboutCtrl.$inject = [];
21

3-
function aboutCtrl() {}
2+
function aboutCtrl() { }
3+
4+
aboutCtrl.$inject = [];
45

56
export default {
6-
templateUrl: "./aboutComponent.html",
7-
controller: aboutCtrl
8-
};
7+
controller: aboutCtrl,
8+
templateUrl: './aboutComponent.html'
9+
};

src/about/aboutModule.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import angular from "angular";
2-
3-
import aboutComponent from "./aboutComp/aboutComponent";
1+
import angular from 'angular';
2+
import aboutComponent from './aboutComp/aboutComponent';
43

54
const ABOUT_MODULE = angular
6-
.module("AboutModule", [])
5+
.module('AboutModule', [])
76
.config([
8-
"$stateProvider",
9-
function($stateProvider) {
7+
'$stateProvider',
8+
($stateProvider) => {
109
// any two of the way can be used
1110
// $stateRegistry.register({
1211
// name: "about",
1312
// url: "/about",
1413
// component: "aboutComponent"
1514
// });
16-
$stateProvider.state("about", {
17-
url: "/about",
18-
component: "aboutComponent"
15+
$stateProvider.state('about', {
16+
component: 'aboutComponent',
17+
url: '/about'
1918
});
2019
}
2120
])
22-
.component("aboutComponent", aboutComponent);
21+
.component('aboutComponent', aboutComponent);
2322

2423
export default ABOUT_MODULE;

src/app.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import "./styles.scss";
2-
import angular from "angular";
3-
4-
import appModule from "./app.module";
5-
6-
import routerConfig from "./route";
7-
import rootComponent from "./rootComponent";
8-
import landingComponent from "./landing/landingComponent";
9-
import headerComponent from "./header/headerComponent";
10-
import "./help/helpController";
11-
import tableDirective from "./landing/tableDir";
1+
import './styles.scss';
2+
import angular from 'angular';
3+
import appModule from './app.module';
4+
import routerConfig from './route';
5+
import rootComponent from './rootComponent';
6+
import landingComponent from './landing/landingComponent';
7+
import headerComponent from './header/headerComponent';
8+
import './help/helpController';
9+
import tableDirective from './landing/tableDir';
1210

1311
appModule
1412
.config(routerConfig)
15-
.component("root", rootComponent)
16-
.component("header", headerComponent)
17-
.component("landingComponent", landingComponent)
13+
.component('root', rootComponent)
14+
.component('header', headerComponent)
15+
.component('landingComponent', landingComponent)
1816

19-
.directive("tableDirective", tableDirective);
17+
.directive('tableDirective', tableDirective);
2018

21-
angular.element(function() {
22-
angular.bootstrap(document, ["angularReact"]);
19+
angular.element(() => {
20+
angular.bootstrap(document, ['angularReact']);
2321
});

src/app.module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import angular from "angular";
1+
import angular from 'angular';
22

3-
const appModule = angular.module("angularReact", ["ui.router", "oc.lazyLoad"]);
3+
const appModule = angular.module('angularReact', ['ui.router', 'oc.lazyLoad']);
44

55
export default appModule;

src/common/table/tableComponent.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { Component } from "react";
2-
import PropTypes from "prop-types";
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
33

44
class Table extends Component {
55
constructor(props) {
66
super(props);
77
}
88

99
componentDidMount() {
10-
console.log("componentDidMount");
10+
console.log('componentDidMount');
1111
}
1212

1313
render() {

src/common/table/tableComponent.spec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import React from "react";
2-
import { shallow } from "enzyme";
3-
import Table from "./tableComponent";
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import Table from './tableComponent';
44

5-
describe("Table", () => {
6-
it("should render correctly", () => {
5+
describe('Table', () => {
6+
// eslint-disable-next-line jest/expect-expect
7+
it('should render correctly', () => {
78
shallow(<Table />);
89
});
910

10-
it("should render initial layout", () => {
11+
it('should render initial layout', () => {
1112
const component = shallow(<Table />);
1213
expect(component.getElements()).toMatchSnapshot();
1314
});

0 commit comments

Comments
 (0)