Skip to content

Commit 8117093

Browse files
Merge pull request janjakubnanista#3 from janjakubnanista/0--eslint
Update ESLint & add linting to commit hooks
2 parents 2fc6eec + 38dccd0 commit 8117093

21 files changed

Lines changed: 1389 additions & 569 deletions

.eslintrc

Lines changed: 0 additions & 137 deletions
This file was deleted.

.eslintrc.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
extends: [
4+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
5+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
6+
'plugin:prettier/recommended',
7+
],
8+
plugins: [
9+
'sort-imports-es6-autofix',
10+
],
11+
parserOptions: {
12+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
13+
sourceType: 'module', // Allows for the use of imports
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
},
18+
overrides: [{
19+
files: ['*.js'],
20+
rules: {
21+
// And as mentioned here this rule will freak out on .js files as well
22+
// https://github.com/typescript-eslint/typescript-eslint/issues/906
23+
//
24+
// So we disable it for .js files using overrides
25+
'@typescript-eslint/explicit-function-return-type': 0,
26+
27+
// And the same goes for member accessibility
28+
//
29+
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md
30+
'@typescript-eslint/explicit-member-accessibility': 0,
31+
32+
// And last but not least require() calls are enabled in js files
33+
'@typescript-eslint/no-var-requires': 0
34+
}
35+
}],
36+
rules: {
37+
// Place to put our Quin-specific rules
38+
39+
// Prevent forgotten console.* statements
40+
"no-console": 2,
41+
42+
"react/prop-types": 0,
43+
44+
// Make sure imports get sorted
45+
"sort-imports-es6-autofix/sort-imports-es6": [2, {
46+
"ignoreCase": false,
47+
"ignoreMemberSort": false,
48+
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
49+
}],
50+
51+
// A special case in which to ignore camelcase found in rollup.config.js
52+
"@typescript-eslint/camelcase": [1, {
53+
"allow": ["screw_ie8"]
54+
}],
55+
56+
"@typescript-eslint/no-use-before-define": [2, { "variables": false }],
57+
58+
"@typescript-eslint/explicit-function-return-type": 0
59+
},
60+
settings: {
61+
react: {
62+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
63+
},
64+
"import/resolver": {
65+
node: {
66+
extensions: [".ts", ".tsx", ".js", ".jsx"]
67+
}
68+
}
69+
},
70+
};

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 2,
7+
};

demo/src/app/components/App.tsx

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import React from "react";
2-
import { AppBar, Toolbar, Typography, CssBaseline, withStyles } from "@material-ui/core";
3-
import { generateRandomData } from "../utils";
4-
import Header from "./Header";
5-
import { XYDataPoint } from "../../../../src/types";
6-
import Chart from "./Chart";
7-
import { DownsamplingMethod } from "../../types";
1+
import { AppBar, CssBaseline, Toolbar, Typography, withStyles } from '@material-ui/core';
2+
import { DownsamplingMethod } from '../../types';
3+
import { XYDataPoint } from '../../../../src/types';
4+
import { generateRandomData } from '../utils';
5+
import Chart from './Chart';
6+
import Header from './Header';
7+
import React from 'react';
88

99
const style = theme => ({
1010
chart: {
11-
padding: theme.spacing.unit * 2
12-
}
11+
padding: theme.spacing.unit * 2,
12+
},
1313
});
1414

1515
export interface AppProps {
1616
classes: {
17-
chart: string
18-
}
17+
chart: string;
18+
};
1919
}
2020

2121
export interface AppState {
@@ -37,54 +37,59 @@ class App extends React.Component<AppProps, AppState> {
3737
numConfirmedRawDataPoints: 1000,
3838
numDownsampledDataPoints: 100,
3939
numConfirmedDownsampledDataPoints: 100,
40-
data: generateRandomData(1000)
40+
data: generateRandomData(1000),
4141
};
4242
}
4343

44-
private onActiveDownsamplingMethodsChange = (activeDownsamplingMethods: DownsamplingMethod[]) => this.setState({ activeDownsamplingMethods })
44+
private onActiveDownsamplingMethodsChange = (activeDownsamplingMethods: DownsamplingMethod[]) =>
45+
this.setState({ activeDownsamplingMethods });
4546

46-
private onNumRawDataPointsChange = (numRawDataPoints: number): void => this.setState(() => ({ numRawDataPoints }))
47+
private onNumRawDataPointsChange = (numRawDataPoints: number): void => this.setState(() => ({ numRawDataPoints }));
4748

4849
private onNumRawDataPointsConfirm = (): void => {
4950
const numConfirmedRawDataPoints = this.state.numRawDataPoints;
5051
const data: XYDataPoint[] = generateRandomData(numConfirmedRawDataPoints);
5152

5253
this.setState(() => ({ data, numConfirmedRawDataPoints }));
53-
}
54+
};
5455

55-
private onNumDownsampledDataPointsChange = (numDownsampledDataPoints: number): void => this.setState({ numDownsampledDataPoints });
56+
private onNumDownsampledDataPointsChange = (numDownsampledDataPoints: number): void =>
57+
this.setState({ numDownsampledDataPoints });
5658

5759
render(): React.ReactNode {
58-
return <React.Fragment>
59-
<CssBaseline/>
60+
return (
61+
<React.Fragment>
62+
<CssBaseline />
6063

61-
<AppBar position="static" color="default">
62-
<Toolbar>
63-
<Typography variant="title" color="inherit">
64-
Downsample
65-
</Typography>
66-
</Toolbar>
67-
</AppBar>
64+
<AppBar position="static" color="default">
65+
<Toolbar>
66+
<Typography variant="title" color="inherit">
67+
Downsample
68+
</Typography>
69+
</Toolbar>
70+
</AppBar>
6871

69-
<Typography component="div">
70-
<Header
71-
numRawDataPoints={this.state.numRawDataPoints}
72-
numDownsampledDataPoints={this.state.numDownsampledDataPoints}
73-
onNumRawDataPointsChange={this.onNumRawDataPointsChange}
74-
onNumDownsampledDataPointsChange={this.onNumDownsampledDataPointsChange}
75-
onNumRawDataPointsConfirm={this.onNumRawDataPointsConfirm}
76-
/>
77-
78-
<div className={this.props.classes.chart}>
79-
<Chart
80-
activeDownsamplingMethods={this.state.activeDownsamplingMethods}
81-
data={this.state.data}
72+
<Typography component="div">
73+
<Header
74+
numRawDataPoints={this.state.numRawDataPoints}
8275
numDownsampledDataPoints={this.state.numDownsampledDataPoints}
83-
onActiveDownsamplingMethodsChange={this.onActiveDownsamplingMethodsChange}/>
84-
</div>
85-
</Typography>
86-
</React.Fragment>;
76+
onNumRawDataPointsChange={this.onNumRawDataPointsChange}
77+
onNumDownsampledDataPointsChange={this.onNumDownsampledDataPointsChange}
78+
onNumRawDataPointsConfirm={this.onNumRawDataPointsConfirm}
79+
/>
80+
81+
<div className={this.props.classes.chart}>
82+
<Chart
83+
activeDownsamplingMethods={this.state.activeDownsamplingMethods}
84+
data={this.state.data}
85+
numDownsampledDataPoints={this.state.numDownsampledDataPoints}
86+
onActiveDownsamplingMethodsChange={this.onActiveDownsamplingMethodsChange}
87+
/>
88+
</div>
89+
</Typography>
90+
</React.Fragment>
91+
);
8792
}
8893
}
8994

90-
export default withStyles(style)(App);
95+
export default withStyles(style)(App);

0 commit comments

Comments
 (0)