Skip to content

Commit 862fdf5

Browse files
Merge pull request #72 from valerybugakov/vb/chore/eslint
Tslint -> Eslint
2 parents e91ea0c + b3eff59 commit 862fdf5

13 files changed

+2150
-1298
lines changed

.eslintrc.js

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
extends: [
5+
'airbnb',
6+
'plugin:@typescript-eslint/eslint-recommended',
7+
'plugin:@typescript-eslint/recommended',
8+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
9+
'prettier',
10+
'prettier/react',
11+
'prettier/@typescript-eslint'
12+
],
13+
env: {
14+
browser: true,
15+
es6: true
16+
},
17+
parser: '@typescript-eslint/parser',
18+
parserOptions: {
19+
project: path.resolve(__dirname, './tsconfig.test.json'),
20+
sourceType: 'module'
21+
},
22+
settings: {
23+
'import/resolver': {
24+
node: {
25+
extensions: ['.js', '.jsx', '.ts', '.tsx']
26+
}
27+
}
28+
},
29+
ignorePatterns: ['/generated.tsx', 'node_modules/'],
30+
plugins: ['prettier', '@typescript-eslint'],
31+
rules: {
32+
'prettier/prettier': 'error',
33+
'@typescript-eslint/no-explicit-any': 'off',
34+
'@typescript-eslint/no-use-before-define': 'off',
35+
'@typescript-eslint/no-non-null-assertion': 'off',
36+
'@typescript-eslint/explicit-function-return-type': 'off',
37+
'@typescript-eslint/interface-name-prefix': 'off',
38+
'@typescript-eslint/class-name-casing': 'error',
39+
'@typescript-eslint/camelcase': 'off',
40+
'@typescript-eslint/indent': 'off',
41+
'@typescript-eslint/no-param-reassign': 'off',
42+
'@typescript-eslint/no-this-alias': 'error',
43+
'@typescript-eslint/quotes': 'off',
44+
'@typescript-eslint/space-within-parens': ['off', 'never'],
45+
'@typescript-eslint/type-annotation-spacing': 'off',
46+
'@typescript-eslint/ban-ts-ignore': 'off',
47+
'@typescript-eslint/prefer-regexp-exec': 'off',
48+
'@typescript-eslint/no-var-requires': 'off',
49+
'@typescript-eslint/unbound-method': 'off',
50+
'@typescript-eslint/no-empty-function': 'off',
51+
'no-unused-vars': 'off',
52+
'@typescript-eslint/no-unused-vars': [
53+
'error',
54+
{
55+
vars: 'all',
56+
args: 'after-used',
57+
argsIgnorePattern: '^_',
58+
ignoreRestSiblings: false,
59+
ignoreRestSiblings: true,
60+
caughtErrorsIgnorePattern: '^ignore'
61+
}
62+
],
63+
'arrow-parens': ['off', 'as-needed'],
64+
camelcase: 'off',
65+
'capitalized-comments': 'error',
66+
'consistent-return': 'off',
67+
'class-methods-use-this': 'off',
68+
'eol-last': 'off',
69+
eqeqeq: ['error', 'smart'],
70+
'id-blacklist': 'off',
71+
'id-match': 'error',
72+
'global-require': 'off',
73+
'linebreak-style': 'off',
74+
'new-parens': 'off',
75+
'newline-per-chained-call': 'off',
76+
'no-var': 'error',
77+
'no-bitwise': 'off',
78+
'no-eval': 'error',
79+
'no-empty': 'off',
80+
'no-plusplus': 'off',
81+
'no-console': 'off',
82+
'no-cond-assign': 'off',
83+
'no-new-wrappers': 'error',
84+
'no-param-reassign': 'off',
85+
'no-underscore-dangle': 'off',
86+
'no-restricted-syntax': 'off',
87+
'no-prototype-builtins': 'off',
88+
'no-duplicate-imports': 'error',
89+
'no-useless-constructor': 'off',
90+
'object-shorthand': 'error',
91+
'one-var': ['error', 'never'],
92+
'padding-line-between-statements': [
93+
'error',
94+
{
95+
blankLine: 'always',
96+
prev: '*',
97+
next: 'return'
98+
}
99+
],
100+
'prefer-const': 'error',
101+
'prefer-template': 'error',
102+
'quote-props': 'off',
103+
radix: 'off',
104+
'space-before-function-paren': 'off',
105+
'spaced-comment': 'error',
106+
107+
'import/order': 'error',
108+
'import/extensions': 'off',
109+
'import/no-unresolved': 'off',
110+
'import/no-extraneous-dependencies': 'off',
111+
'import/prefer-default-export': 'off',
112+
'import/no-dynamic-require': 'off',
113+
114+
'react/jsx-key': 'error',
115+
'react/jsx-no-bind': 'error',
116+
'react/self-closing-comp': 'error',
117+
'react/state-in-constructor': 'off',
118+
'react/jsx-props-no-spreading': 'off',
119+
'react/no-did-update-set-state': 'off',
120+
'react/prefer-stateless-function': 'off',
121+
'react/destructuring-assignment': 'off',
122+
'react/jsx-one-expression-per-line': 'off',
123+
'react/jsx-boolean-value': ['error', 'always'],
124+
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
125+
'react/jsx-no-bind': 'off',
126+
'react/no-unescaped-entities': 'off',
127+
'react/static-property-placement': 'off',
128+
'react/prop-types': 'off',
129+
'react/sort-comp': [
130+
'error',
131+
{
132+
order: [
133+
'static-variables',
134+
'static-methods',
135+
'instance-variables',
136+
'type-annotations',
137+
'lifecycle',
138+
'everything-else',
139+
'/^on.+$/',
140+
'/^handle.+$/',
141+
'rendering'
142+
],
143+
groups: {
144+
rendering: ['/^render.+$/', 'render']
145+
}
146+
}
147+
],
148+
149+
'jsx-a11y/anchor-is-valid': 'off',
150+
'jsx-a11y/alt-text': 'off'
151+
}
152+
}

.prettierrc

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

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parser": "typescript",
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"semi": false
6+
}

example/src/App.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,41 @@ type TAppProps = {
99
items: TAlbumItem[]
1010
}
1111

12-
class App extends Component<TAppProps> {
12+
type TAppState = {
13+
disableFirstRow: boolean
14+
reversed: boolean
15+
}
16+
17+
class App extends Component<TAppProps, TAppState> {
1318
state = {
1419
disableFirstRow: false,
1520
reversed: false
1621
}
1722

1823
countersRef = createRef<Counters>()
1924

20-
handleSelecting = selectingItems => {
21-
this.countersRef.current.handleSelecting(selectingItems)
25+
getSelectableGroupRef = (ref: SelectableGroup | null) => {
26+
;(window as any).selectableGroup = ref
2227
}
2328

24-
handleSelectionFinish = selectedItems => {
25-
this.countersRef.current.handleSelectionFinish(selectedItems)
29+
toggleFirstRow = () => {
30+
this.setState(state => ({ disableFirstRow: !state.disableFirstRow }))
2631
}
2732

28-
handleSelectionClear() {
29-
console.log('Cancel selection')
33+
toggleOrder = () => {
34+
this.setState(state => ({ reversed: !state.reversed }))
3035
}
3136

32-
toggleFirstRow = () => {
33-
this.setState({ disableFirstRow: !this.state.disableFirstRow })
37+
handleSelecting = (selectingItems: TAlbumItem) => {
38+
this.countersRef.current.handleSelecting(selectingItems)
3439
}
3540

36-
toggleOrder = () => {
37-
this.setState({ reversed: !this.state.reversed })
41+
handleSelectionFinish = selectedItems => {
42+
this.countersRef.current.handleSelectionFinish(selectedItems)
3843
}
3944

40-
getSelectableGroupRef = (ref: SelectableGroup | null) => {
41-
;(window as any).selectableGroup = ref
45+
handleSelectionClear() {
46+
console.log('Cancel selection')
4247
}
4348

4449
render() {

package.json

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-selectable-fast",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch",
55
"repository": {
66
"type": "git",
@@ -15,8 +15,8 @@
1515
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
1616
"prepublishOnly": "yarn lint && yarn clean && yarn build:prod && yarn transpile",
1717
"prettier": "prettier --write src/**/*.{js,ts,tsx} example/src/**/*.{js,ts,tsx} .js",
18-
"lint:basic": "tsc --pretty --noEmit && tslint --fix --format codeFrame",
19-
"lint": "yarn lint:basic --project ./tsconfig.json 'src/**/*.{ts,tsx} example/src/**/*.{ts,tsx}'",
18+
"lint:basic": "tsc --pretty --noEmit && eslint --fix --format codeframe",
19+
"lint": "yarn lint:basic '{example/,}src/**/*.{ts,tsx}'",
2020
"format": "yarn prettier && yarn lint",
2121
"test": "yarn lint",
2222
"watch:example": "webpack-dev-server --config ./example/webpack.config.example.js --content-base website",
@@ -25,8 +25,7 @@
2525
"lint-staged": {
2626
"*.{js,ts,tsx}": [
2727
"prettier --write",
28-
"yarn lint:basic",
29-
"git add"
28+
"yarn lint:basic"
3029
]
3130
},
3231
"husky": {
@@ -69,32 +68,38 @@
6968
"react-dom": ">=16.6.0"
7069
},
7170
"devDependencies": {
72-
"@babel/cli": "^7.5.5",
73-
"@babel/core": "^7.5.5",
74-
"@babel/plugin-proposal-class-properties": "^7.5.5",
75-
"@babel/preset-env": "^7.5.5",
76-
"@babel/preset-react": "^7.0.0",
77-
"@babel/preset-typescript": "^7.3.3",
78-
"@types/react": "^16.9.1",
79-
"@types/react-dom": "^16.8.5",
71+
"@babel/cli": "^7.8.4",
72+
"@babel/core": "^7.8.4",
73+
"@babel/plugin-proposal-class-properties": "^7.8.3",
74+
"@babel/preset-env": "^7.8.4",
75+
"@babel/preset-react": "^7.8.3",
76+
"@babel/preset-typescript": "^7.8.3",
77+
"@types/react": "^16.9.22",
78+
"@types/react-dom": "^16.9.5",
79+
"@typescript-eslint/eslint-plugin": "^2.17.0",
80+
"@typescript-eslint/parser": "^2.17.0",
8081
"babel-loader": "^8.0.6",
8182
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
82-
"cross-env": "^5.2.0",
83-
"husky": "^3.0.3",
84-
"lint-staged": "^9.2.0",
83+
"cross-env": "^7.0.0",
84+
"eslint": "6.8.0",
85+
"eslint-config-airbnb": "18.0.1",
86+
"eslint-config-prettier": "^6.5.0",
87+
"eslint-plugin-import": "^2.18.2",
88+
"eslint-plugin-jsx-a11y": "^6.2.3",
89+
"eslint-plugin-prettier": "^3.1.1",
90+
"eslint-plugin-react": "^7.18.0",
91+
"eslint-plugin-react-hooks": "^2.2.0",
92+
"husky": "^4.2.3",
93+
"lint-staged": "^10.0.7",
8594
"prettier": "^1.18.2",
8695
"prop-types": "^15.7.2",
8796
"react": "^16.8.6",
8897
"react-dom": "^16.8.6",
89-
"rimraf": "^2.6.3",
90-
"tslint": "^5.18.0",
91-
"tslint-config-airbnb": "^5.11.1",
92-
"tslint-config-prettier": "^1.18.0",
93-
"tslint-react": "^4.0.0",
94-
"typescript": "^3.5.3",
95-
"webpack": "^4.36.1",
98+
"rimraf": "^3.0.2",
99+
"typescript": "^3.8.2",
100+
"webpack": "^4.41.6",
96101
"webpack-bundle-analyzer": "^3.3.2",
97-
"webpack-cli": "^3.3.6",
98-
"webpack-dev-server": "^3.7.2"
102+
"webpack-cli": "^3.3.11",
103+
"webpack-dev-server": "^3.10.3"
99104
}
100105
}

src/CreateSelectable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const createSelectable = (WrappedComponent: ComponentType<any>) =>
2323
}
2424

2525
node: HTMLElement | null = null
26+
2627
bounds: TComputedBounds | null = null
2728

2829
componentDidMount() {

0 commit comments

Comments
 (0)