Skip to content

Commit

Permalink
Merge pull request #72 from valerybugakov/vb/chore/eslint
Browse files Browse the repository at this point in the history
Tslint -> Eslint
  • Loading branch information
valerybugakov authored Feb 23, 2020
2 parents e91ea0c + b3eff59 commit 862fdf5
Show file tree
Hide file tree
Showing 13 changed files with 2,150 additions and 1,298 deletions.
152 changes: 152 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
const path = require('path')

module.exports = {
extends: [
'airbnb',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'prettier/react',
'prettier/@typescript-eslint'
],
env: {
browser: true,
es6: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: path.resolve(__dirname, './tsconfig.test.json'),
sourceType: 'module'
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
},
ignorePatterns: ['/generated.tsx', 'node_modules/'],
plugins: ['prettier', '@typescript-eslint'],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/class-name-casing': 'error',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-param-reassign': 'off',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/space-within-parens': ['off', 'never'],
'@typescript-eslint/type-annotation-spacing': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: false,
ignoreRestSiblings: true,
caughtErrorsIgnorePattern: '^ignore'
}
],
'arrow-parens': ['off', 'as-needed'],
camelcase: 'off',
'capitalized-comments': 'error',
'consistent-return': 'off',
'class-methods-use-this': 'off',
'eol-last': 'off',
eqeqeq: ['error', 'smart'],
'id-blacklist': 'off',
'id-match': 'error',
'global-require': 'off',
'linebreak-style': 'off',
'new-parens': 'off',
'newline-per-chained-call': 'off',
'no-var': 'error',
'no-bitwise': 'off',
'no-eval': 'error',
'no-empty': 'off',
'no-plusplus': 'off',
'no-console': 'off',
'no-cond-assign': 'off',
'no-new-wrappers': 'error',
'no-param-reassign': 'off',
'no-underscore-dangle': 'off',
'no-restricted-syntax': 'off',
'no-prototype-builtins': 'off',
'no-duplicate-imports': 'error',
'no-useless-constructor': 'off',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: '*',
next: 'return'
}
],
'prefer-const': 'error',
'prefer-template': 'error',
'quote-props': 'off',
radix: 'off',
'space-before-function-paren': 'off',
'spaced-comment': 'error',

'import/order': 'error',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'import/no-dynamic-require': 'off',

'react/jsx-key': 'error',
'react/jsx-no-bind': 'error',
'react/self-closing-comp': 'error',
'react/state-in-constructor': 'off',
'react/jsx-props-no-spreading': 'off',
'react/no-did-update-set-state': 'off',
'react/prefer-stateless-function': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/jsx-boolean-value': ['error', 'always'],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'react/jsx-no-bind': 'off',
'react/no-unescaped-entities': 'off',
'react/static-property-placement': 'off',
'react/prop-types': 'off',
'react/sort-comp': [
'error',
{
order: [
'static-variables',
'static-methods',
'instance-variables',
'type-annotations',
'lifecycle',
'everything-else',
'/^on.+$/',
'/^handle.+$/',
'rendering'
],
groups: {
rendering: ['/^render.+$/', 'render']
}
}
],

'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/alt-text': 'off'
}
}
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parser": "typescript",
"singleQuote": true,
"printWidth": 100,
"semi": false
}
31 changes: 18 additions & 13 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,41 @@ type TAppProps = {
items: TAlbumItem[]
}

class App extends Component<TAppProps> {
type TAppState = {
disableFirstRow: boolean
reversed: boolean
}

class App extends Component<TAppProps, TAppState> {
state = {
disableFirstRow: false,
reversed: false
}

countersRef = createRef<Counters>()

handleSelecting = selectingItems => {
this.countersRef.current.handleSelecting(selectingItems)
getSelectableGroupRef = (ref: SelectableGroup | null) => {
;(window as any).selectableGroup = ref
}

handleSelectionFinish = selectedItems => {
this.countersRef.current.handleSelectionFinish(selectedItems)
toggleFirstRow = () => {
this.setState(state => ({ disableFirstRow: !state.disableFirstRow }))
}

handleSelectionClear() {
console.log('Cancel selection')
toggleOrder = () => {
this.setState(state => ({ reversed: !state.reversed }))
}

toggleFirstRow = () => {
this.setState({ disableFirstRow: !this.state.disableFirstRow })
handleSelecting = (selectingItems: TAlbumItem) => {
this.countersRef.current.handleSelecting(selectingItems)
}

toggleOrder = () => {
this.setState({ reversed: !this.state.reversed })
handleSelectionFinish = selectedItems => {
this.countersRef.current.handleSelectionFinish(selectedItems)
}

getSelectableGroupRef = (ref: SelectableGroup | null) => {
;(window as any).selectableGroup = ref
handleSelectionClear() {
console.log('Cancel selection')
}

render() {
Expand Down
55 changes: 30 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-selectable-fast",
"version": "3.2.0",
"version": "3.2.1",
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch",
"repository": {
"type": "git",
Expand All @@ -15,8 +15,8 @@
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"prepublishOnly": "yarn lint && yarn clean && yarn build:prod && yarn transpile",
"prettier": "prettier --write src/**/*.{js,ts,tsx} example/src/**/*.{js,ts,tsx} .js",
"lint:basic": "tsc --pretty --noEmit && tslint --fix --format codeFrame",
"lint": "yarn lint:basic --project ./tsconfig.json 'src/**/*.{ts,tsx} example/src/**/*.{ts,tsx}'",
"lint:basic": "tsc --pretty --noEmit && eslint --fix --format codeframe",
"lint": "yarn lint:basic '{example/,}src/**/*.{ts,tsx}'",
"format": "yarn prettier && yarn lint",
"test": "yarn lint",
"watch:example": "webpack-dev-server --config ./example/webpack.config.example.js --content-base website",
Expand All @@ -25,8 +25,7 @@
"lint-staged": {
"*.{js,ts,tsx}": [
"prettier --write",
"yarn lint:basic",
"git add"
"yarn lint:basic"
]
},
"husky": {
Expand Down Expand Up @@ -69,32 +68,38 @@
"react-dom": ">=16.6.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/react": "^16.9.1",
"@types/react-dom": "^16.8.5",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@types/react": "^16.9.22",
"@types/react-dom": "^16.9.5",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"cross-env": "^5.2.0",
"husky": "^3.0.3",
"lint-staged": "^9.2.0",
"cross-env": "^7.0.0",
"eslint": "6.8.0",
"eslint-config-airbnb": "18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.18.0",
"eslint-plugin-react-hooks": "^2.2.0",
"husky": "^4.2.3",
"lint-staged": "^10.0.7",
"prettier": "^1.18.2",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"tslint": "^5.18.0",
"tslint-config-airbnb": "^5.11.1",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0",
"typescript": "^3.5.3",
"webpack": "^4.36.1",
"rimraf": "^3.0.2",
"typescript": "^3.8.2",
"webpack": "^4.41.6",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2"
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
}
1 change: 1 addition & 0 deletions src/CreateSelectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const createSelectable = (WrappedComponent: ComponentType<any>) =>
}

node: HTMLElement | null = null

bounds: TComputedBounds | null = null

componentDidMount() {
Expand Down
Loading

1 comment on commit 862fdf5

@vercel
Copy link

@vercel vercel bot commented on 862fdf5 Feb 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.