Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Nov 4, 2023
1 parent 38a8c99 commit 3b6e150
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 104 deletions.
146 changes: 48 additions & 98 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,115 +1,65 @@
'use strict';

module.exports = {
extends: 'eslint-config-airbnb',
parser: '@babel/eslint-parser',
/* eslint-env node */
const eslintConfig = {
extends: 'eslint-config-egg',
env: {
browser: true,
es6: true,
node: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
requireConfigFile: false,
ecmaVersion: 2020,
ecmaFeatures: {
jsx: true,
},
babelOptions: {
presets: ['@babel/preset-react'],
experimentalObjectRestSpread: true,
},
},
plugins: [
'babel',
'react',
'compat',
'no-only-tests',
'react-hooks',
],
ignorePatterns: ['*.d.ts'],
overrides: [],
};

const tslintConfig = {
// enable the rule specifically for TypeScript files
files: [
'*.js',
'*.jsx',
'*.ts',
'*.tsx',
],
extends: [
'eslint-config-egg/typescript',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
rules: {
camelcase: 0,
'no-restricted-syntax': 0,
'no-plusplus': 0,
'no-underscore-dangle': 0,
'no-useless-escape': 0,
'no-unused-vars': ['error', { args: 'none' }],
'no-prototype-builtins': 0,
'max-len': 0,
'class-methods-use-this': 0,
'function-paren-newline': 0,
'react/no-array-index-key': 0,
'react/no-danger': 0,
'react/jsx-no-undef': [2, { allowGlobals: true }],
'react/no-find-dom-node': 0,
'react/no-did-mount-set-state': 0,
'react/jsx-no-target-blank': 0,
'react/no-did-update-set-state': 0,
'react/prop-types': 0,
'react/jsx-filename-extension': 0,
'react/sort-comp': 0,
'react/require-default-props': 0,
'react/no-typos': 0,
'react/forbid-prop-types': 0,
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'react/jsx-one-expression-per-line': 0,
'react/destructuring-assignment': 0,
'react/no-unused-prop-types': ['warn'],
'react/self-closing-comp': 0,
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/anchor-has-content': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/alt-text': 0,
'jsx-a11y/mouse-events-have-key-events': 0,
'jsx-a11y/iframe-has-title': 0,
'jsx-a11y/media-has-caption': 0,
'jsx-a11y/tabindex-no-positive': 0,
'jsx-a11y/aria-role': 0,
'jsx-a11y/no-noninteractive-tabindex': 0,
'jsx-a11y/label-has-for': 0,
'jsx-a11y/accessible-emoji': 0,
'no-await-in-loop': 0,
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
}],
'no-param-reassign': 0,
'consistent-return': 0,
'object-curly-newline': ['error', { consistent: true, minProperties: 6 }],
'arrow-parens': 0,
'arrow-body-style': ['warn'],
'prefer-destructuring': ['error', {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
...eslintConfig.rules,
'no-unused-vars': 1,
'no-undef': 'off',
'no-use-before-define': 'off',
'no-bitwise': 'warn',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': ['warn'],
'no-multiple-empty-lines': [
'error',
{
max: 1,
maxEOF: 0,
maxBOF: 0,
},
}],
'import/named': 0,
'import/no-extraneous-dependencies': 0,
'no-mixed-operators': 0,
'no-shadow': 0,
'no-useless-constructor': 0,
'no-return-assign': 0,
'prefer-rest-params': 0,
'no-restricted-globals': [0, 'location'],
'prefer-promise-reject-errors': 0,
'no-bitwise': 0,
'no-return-await': 0,
'import/prefer-default-export': 0,
'func-names': 0,
'no-use-before-define': 0,
'global-require': 0,
'no-else-return': 0,
'no-lonely-if': 0,
'guard-for-in': 0,
'one-var': 0,
'one-var-declaration-per-line': 0,
'no-console': 2,
],
},
};

eslintConfig.overrides.push(tslintConfig);

module.exports = eslintConfig;
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@babel/plugin-transform-runtime": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@babel/preset-react": "^7.14.5",
"@typescript-eslint/parser": "^6.9.1",
"babel-eslint": "^10.1.0",
"babel-loader": "8",
"babel-plugin-istanbul": "^6.1.1",
Expand All @@ -60,6 +61,7 @@
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-react-hooks": "^4.6.0",
"forkmeon.github.io": "1.1.15",
"git-contributor": "1",
"highlight.js": "^11.2.0",
Expand All @@ -76,6 +78,7 @@
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-logo": "^1.0.15",
"typescript": "^5.2.2",
"webpack": "5",
"webpack-cli": "^4.9.0",
"webpack-dev-server": "^4.7.4"
Expand Down
5 changes: 3 additions & 2 deletions src/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function transitionEnd() {

const ifHasTransitionEnd = transitionEnd();

const prefixes = ['Webkit', 'Moz', 'ms', 'O', ''];
const prefixes = [ 'Webkit', 'Moz', 'ms', 'O', '' ];

class AnimationManager {
constructor() {
Expand Down Expand Up @@ -51,7 +51,8 @@ class AnimationManager {
const style = {};

prefixes.forEach(prefix => {
let x, y;
let x;
let y;

if (this.horizontalDirection === 'right') {
x = this.containerWidth - this.size.width - this.position[0] + this.itemMargin;
Expand Down
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const {

const AnimationManager = require('./animation');

const noop = function () {};

class AutoResponsive extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -138,8 +136,8 @@ AutoResponsive.defaultProps = {
transitionTimingFunction: 'linear',
verticalDirection: 'top',
closeAnimation: false,
onItemDidLayout: noop,
onContainerDidLayout: noop,
onItemDidLayout: () => {},
onContainerDidLayout: () => {},
};

module.exports = AutoResponsive;

0 comments on commit 3b6e150

Please sign in to comment.