Skip to content

Commit f8ca28e

Browse files
committed
tslint
1 parent 129ae8c commit f8ca28e

File tree

11 files changed

+1036
-53
lines changed

11 files changed

+1036
-53
lines changed

components/Abstract/SelectionBase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class FieldSelectionBase extends FieldCoreBase<IProps> {
6262
<FormControlLabel
6363
className={helperText ? classes.containerAlign : null}
6464
control={
65-
checked ? //force recreation
65+
checked ? //force recreation
6666
<Component
6767
checked={true}
6868
disabled={disabled}

components/Autocomplete/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ export default class FieldAutocomplete extends FieldCoreBase<IProps, IState> {
126126
this.onChange(null);
127127
}
128128

129+
shouldRenderSuggestions = () => true;
130+
129131
render() {
130132
const { term, suggestions } = this.state;
131133
const { classes, placeholder, disabled, label } = this.props;
@@ -144,7 +146,7 @@ export default class FieldAutocomplete extends FieldCoreBase<IProps, IState> {
144146
}}
145147
renderInputComponent={Input}
146148
renderSuggestionsContainer={SuggestionsContainer}
147-
shouldRenderSuggestions={() => true}
149+
shouldRenderSuggestions={this.shouldRenderSuggestions}
148150
onSuggestionsFetchRequested={this.handleSuggestionsFetchRequested}
149151
onSuggestionsClearRequested={this.handleSuggestionsClearRequested}
150152
getSuggestionValue={this.getSuggestionValue}

components/Checkbox.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import FieldSelectionBase, { IPropsSelectionBase } from './Abstract/SelectionBas
55

66
export default class FieldCheckbox extends React.PureComponent<IPropsSelectionBase> {
77
render() {
8-
return <FieldSelectionBase
9-
{...this.props}
10-
value={this.props.value || null}
11-
Component={Checkbox}
12-
/>;
8+
return (
9+
<FieldSelectionBase
10+
{...this.props}
11+
value={this.props.value || null}
12+
Component={Checkbox}
13+
/>
14+
);
1315
}
1416
}

components/Color/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ export default class FieldColor extends FieldCoreBase<IProps, IState> {
1919
this.state = { ...this.state, showPicker: false };
2020
}
2121

22-
setShowPicker = (showPicker: boolean) => {
23-
this.setState({ showPicker });
24-
}
22+
showPicker = () => this.setState({ showPicker: true });
23+
hidePicker = () => this.setState({ showPicker: false });
2524

2625
onChange = (event: any) => {
2726
getConfig().validationOn === 'onChange' && this.setState({ showError: true });
@@ -56,14 +55,14 @@ export default class FieldColor extends FieldCoreBase<IProps, IState> {
5655
touched: null,
5756
loading: null
5857
}}
59-
onClick={() => this.setShowPicker(true)}
58+
onClick={this.showPicker}
6059
InputProps={{ style: { color: value } }}
6160
/>
6261
{showPicker && (
6362
<PickerDialog
6463
value={value || ''}
65-
onDismiss={() => this.setShowPicker(false)}
66-
onChange={e => this.onChange(e)}
64+
onDismiss={this.hidePicker}
65+
onChange={this.onChange}
6766
/>
6867
)}
6968
</React.Fragment>

components/CustomMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import CustomMessageComponent from '@react-form-fields/core/components/CustomMessage';
1+
import CustomMessage from '@react-form-fields/core/components/CustomMessage';
22

3-
export default CustomMessageComponent;
3+
export default CustomMessage;

components/Radio.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import FieldSelectionBase, { IPropsSelectionBase } from './Abstract/SelectionBas
55

66
export default class FieldRadio extends React.PureComponent<IPropsSelectionBase> {
77
render() {
8-
return <FieldSelectionBase
9-
{...this.props}
10-
Component={Radio}
11-
/>;
8+
return (
9+
<FieldSelectionBase
10+
{...this.props}
11+
Component={Radio}
12+
/>
13+
);
1214
}
1315
}

components/Switch.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import FieldSelectionBase, { IPropsSelectionBase } from './Abstract/SelectionBas
55

66
export default class FieldSwitch extends React.PureComponent<IPropsSelectionBase> {
77
render() {
8-
return <FieldSelectionBase
9-
{...this.props}
10-
value={this.props.value || null}
11-
Component={Switch}
12-
/>;
8+
return (
9+
<FieldSelectionBase
10+
{...this.props}
11+
value={this.props.value || null}
12+
Component={Switch}
13+
/>
14+
);
1315
}
1416
}

config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare module '@react-form-fields/core/config' {
1111
const defaultConfig: coreConfig.IConfig = {
1212
validationOn: 'onChange',
1313
dateFormat: 'dd/MM/yyyy'
14-
}
14+
};
1515

1616
export function getConfig(): coreConfig.IConfig {
1717
return {

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"validation",
1111
"material"
1212
],
13-
"version": "1.10.0",
13+
"version": "1.10.1",
1414
"main": "./dist/index.js",
1515
"types": "./dist/index.d.ts",
1616
"license": "MIT",
@@ -28,9 +28,14 @@
2828
"scripts": {
2929
"docs:dev": "(cd docs/project && yarn && yarn start)",
3030
"docs:build": "sh docs/build.sh",
31-
"precommit": "yarn tsc --noEmit",
3231
"prepare": "yarn tsc"
3332
},
33+
"husky": {
34+
"hooks": {
35+
"pre-commit": "concurrently -r \"yarn tslint -p tsconfig.json\" \"yarn tsc --noEmit\"",
36+
"post-merge": "yarn"
37+
}
38+
},
3439
"dependencies": {
3540
"@react-form-fields/core": ">=1.1.0",
3641
"autosuggest-highlight": ">=3.0.0",
@@ -52,8 +57,12 @@
5257
"@types/react-autosuggest": "9.3.5",
5358
"@types/react-color": "2.13.6",
5459
"@types/validatorjs": "3.7.1",
55-
"husky": "0.14.3",
60+
"concurrently": "4.1.0",
61+
"husky": "1.2.0",
5662
"react": ">=16.3.0",
63+
"tslint": "5.11.0",
64+
"tslint-eslint-rules": "5.4.0",
65+
"tslint-react": "^3.6.0",
5766
"typescript": "3.0.1"
5867
}
5968
}

tslint.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"extends": "tslint-react",
3+
"rules": {
4+
"adjacent-overload-signatures": true,
5+
"import-blacklist": [
6+
true,
7+
"@material-ui/core",
8+
"@material-ui/icons",
9+
"mdi-react",
10+
"lodash"
11+
],
12+
"indent": [
13+
true,
14+
"spaces"
15+
],
16+
"interface-name": [
17+
true,
18+
"always-prefix"
19+
],
20+
"jsx-boolean-value": [
21+
"never"
22+
],
23+
"jsx-no-multiline-js": false,
24+
"linebreak-style": [
25+
false,
26+
"LF"
27+
],
28+
"max-file-line-count": [
29+
true,
30+
300
31+
],
32+
"max-line-length": [
33+
false,
34+
150
35+
],
36+
"no-consecutive-blank-lines": [
37+
true
38+
],
39+
"no-default-export": false,
40+
"no-duplicate-variable": true,
41+
"no-extra-semi": [
42+
true
43+
],
44+
"no-namespace": [
45+
true,
46+
"allow-declarations"
47+
],
48+
"no-reference": true,
49+
"no-require-imports": false,
50+
"no-trailing-whitespace": true,
51+
"no-var-keyword": [
52+
true
53+
],
54+
"object-literal-key-quotes": [
55+
true,
56+
"as-needed"
57+
],
58+
"object-literal-shorthand": true,
59+
"only-arrow-functions": [
60+
false
61+
],
62+
"quotemark": [
63+
true,
64+
"single"
65+
],
66+
"semicolon": [
67+
true,
68+
"always"
69+
],
70+
"typedef-whitespace": [
71+
true,
72+
{
73+
"call-signature": "nospace",
74+
"index-signature": "nospace",
75+
"parameter": "nospace",
76+
"property-declaration": "nospace",
77+
"variable-declaration": "nospace"
78+
},
79+
{
80+
"call-signature": "onespace",
81+
"index-signature": "onespace",
82+
"parameter": "onespace",
83+
"property-declaration": "onespace",
84+
"variable-declaration": "onespace"
85+
}
86+
]
87+
},
88+
"rulesDirectory": [
89+
"node_modules/tslint-eslint-rules/dist/rules"
90+
]
91+
}

0 commit comments

Comments
 (0)