Skip to content

Commit

Permalink
fix eslint not working and clearnup all eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanshar committed Sep 8, 2019
1 parent e05701d commit 99c9efd
Show file tree
Hide file tree
Showing 109 changed files with 2,067 additions and 1,822 deletions.
128 changes: 73 additions & 55 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,15 @@
// const validColors = require('./src/style/colorsPalette').colorsPalette;
// const extraFixColorsMap = require('./src/style/colorsPalette').extraFixColorsMap;
// const assetsDepJson = require('./eslint-rules/tests/assets_deprecation.json');
// const deprecationsJson = require('./eslint-rules/tests/component_deprecation.json');

module.exports = {
extends: 'wix/react-native',
parser: 'babel-eslint',
plugins: ['react', 'react-native', 'uilib'],
// extends: ['airbnb'],
rules: {
'arrow-body-style': 'off',
'arrow-parens': 'off',
// TODO: remove after migration of legacy lifecycle methods
'camelcase': 'off',
'class-methods-use-this': 'off',
'consistent-return': 'off',
'comma-dangle': 'off',
'global-require': 'off',
'max-len': [2, 130, 4, {ignoreUrls: true}],
'no-nested-ternary': 'off',
'no-else-return': 'off',
camelcase: 'off',
'comma-dangle': ['error', 'never'],
'no-mixed-operators': ['off'],
'no-param-reassign': ['warn'],
'no-plusplus': 'off',
'no-return-assign': 'off',
'no-trailing-spaces': 'off',
'no-use-before-define': 'off',
'no-unneeded-ternary': 'off',
'no-mixed-operators': 'off',
'no-underscore-dangle': ['error', {'allowAfterThis': true}],
'object-curly-spacing': 'off',
'operator-linebreak': 'off',
'react/forbid-prop-types': 'off',
'react/jsx-filename-extension': 'off',
'react/jsx-space-before-closing': 'off',
'react/jsx-tag-spacing': 'off',
// 'react/no-did-mount-set-state': 'warn',
'react/prefer-stateless-function': 'off',
'react/prop-types': ['error', {ignore: ['children', 'style', 'testID']}],
'react/require-default-props': 'off',
"react/sort-comp": ['warn'],
'max-len': ['warn', {code: 120}],
'react/jsx-no-bind': [
'warn',
{
Expand All @@ -47,27 +18,74 @@ module.exports = {
allowBind: false,
},
],
// 'import/no-extraneous-dependencies': [
// 'warn',
// {devDependencies: true, optionalDependencies: false, peerDependencies: true},
// ],
'import/prefer-default-export': 'off',
// 'uilib/assets-deprecation': ['error', {deprecations: assetsDepJson, source: '../../assets', dueDate: '2 November, Friday'}],
// 'uilib/component-deprecation': ['error', {deprecations: deprecationsJson, dueDate: 'Friday 21 December'}],
// 'uilib/no-direct-import': ['error', {origin: 'react-native-ui-lib', destination: 'some-other-source'}],
// 'uilib/no-hard-coded-color': ['error', validColors, extraFixColorsMap],
// 'uilib/no-hard-coded-font': 'error'
},
env: {
browser: true,
node: true,
jest: true,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ios.js', '.android.js'],
},
},
'function-paren-newline': ['warn', 'never'],
'new-cap': ['off'], // TODO: fix this in colors.js and remove this
'default-case': ['off']
},
};

// OLD ESlint configuration
// const validColors = require('./src/style/colorsPalette').colorsPalette;
// const extraFixColorsMap = require('./src/style/colorsPalette').extraFixColorsMap;
// const assetsDepJson = require('./eslint-rules/tests/assets_deprecation.json');
// const deprecationsJson = require('./eslint-rules/tests/component_deprecation.json');

// module.exports = {
// parser: 'babel-eslint',
// extends: 'wix/react-native',
// // plugins: ['react', 'react-native', 'uilib'],
// // extends: ['airbnb'],
// rules: {
// 'arrow-body-style': 'off',
// 'arrow-parens': 'off',
// // TODO: remove after migration of legacy lifecycle methods
// 'camelcase': 'off',
// 'class-methods-use-this': 'off',
// 'consistent-return': 'off',
// 'comma-dangle': 'off',
// 'global-require': 'off',
// 'max-len': [2, 130, 4, {ignoreUrls: true}],
// 'no-nested-ternary': 'off',
// 'no-else-return': 'off',
// 'no-mixed-operators': ['off'],
// 'no-param-reassign': ['warn'],
// 'no-plusplus': 'off',
// 'no-return-assign': 'off',
// 'no-trailing-spaces': 'off',
// 'no-use-before-define': 'off',
// 'no-unneeded-ternary': 'off',
// 'no-mixed-operators': 'off',
// 'no-underscore-dangle': ['error', {'allowAfterThis': true}],
// 'object-curly-spacing': 'off',
// 'operator-linebreak': 'off',
// 'react/forbid-prop-types': 'off',
// 'react/jsx-filename-extension': 'off',
// 'react/jsx-space-before-closing': 'off',
// 'react/jsx-tag-spacing': 'off',
// 'react/prefer-stateless-function': 'off',
// 'react/prop-types': ['error', {ignore: ['children', 'style', 'testID']}],
// 'react/require-default-props': 'off',
// "react/sort-comp": ['warn'],
// 'react/jsx-no-bind': [
// 'warn',
// {
// ignoreRefs: true,
// allowArrowFunctions: false,
// allowBind: false,
// },
// ],
// 'import/prefer-default-export': 'off'
// },
// env: {
// browser: true,
// node: true,
// jest: true,
// },
// settings: {
// 'import/resolver': {
// node: {
// extensions: ['.js', '.ios.js', '.android.js'],
// },
// },
// },
// };
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
"@babel/preset-env": "^7.3.1",
"@babel/runtime": "^7.4.2",
"@react-native-community/async-storage": "1.2.4",
"@react-native-community/eslint-config": "0.0.5",
"@react-native-community/eslint-config": "latest",
"@types/prop-types": "^15.5.3",
"@types/react-native": "^0.55.21",
"babel-jest": "^24.5.0",
"babel-preset-react-native": "*",
"eslint": "^5.16.0",
"eslint-plugin-import": "^2.2.0",
"eslint-config-wix": "^1.1.28",
"eslint-plugin-uilib": "file:./eslint-rules",
"gatsby": "^1.9.128",
"gh-pages": "^1.1.0",
Expand Down
30 changes: 21 additions & 9 deletions src/assets/__tests__/Assets.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Assets } from '../Assets';
import {Assets} from '../Assets';

describe('Assets', () => {
let assets;
Expand All @@ -13,7 +13,7 @@ describe('Assets', () => {
});

it('should create nested groups', () => {
assets.loadAssetsGroup('emojis.ascii', { smile: ':)' });
assets.loadAssetsGroup('emojis.ascii', {smile: ':)'});
expect(assets.emojis.ascii.smile).toBe(':)');
});

Expand All @@ -32,7 +32,7 @@ describe('Assets', () => {
it('should create root asset groups', () => {
const emojis = {};
const icons = {};
assets.loadAssetsGroup('', { emojis, icons });
assets.loadAssetsGroup('', {emojis, icons});

expect(assets.emojis).toBe(emojis);
expect(assets.icons).toBe(icons);
Expand All @@ -47,7 +47,9 @@ describe('Assets', () => {

assets.loadAssetsGroup('', {
emojis,
get icons() { return requireHeavyIcons(); },
get icons() {
return requireHeavyIcons();
}
});

expect(assets.emojis).toBe(emojis);
Expand All @@ -64,20 +66,30 @@ describe('Assets', () => {

beforeEach(() => {
iconsModule = {
get apply() { return './apply.png'; },
get back() { return './back.png'; },
get apply() {
return './apply.png';
},
get back() {
return './back.png';
}
};

assets.loadAssetsGroup('', {
get icons() { return iconsModule; },
get icons() {
return iconsModule;
}
});
});

describe('and called with the same group name', () => {
beforeEach(() => {
assets.loadAssetsGroup('icons', {
get back() { return './back-dark.png'; },
get forward() { return './forward-dark.png'; },
get back() {
return './back-dark.png';
},
get forward() {
return './forward-dark.png';
}
});
});

Expand Down
28 changes: 21 additions & 7 deletions src/assets/icons/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
export const icons = {
get check() { return require('./check.png'); },
get checkSmall() { return require('./check-small.png'); },
get chevronRight() { return require('./chevronRight.png'); },
get plusSmall() { return require('./plusSmall.png'); },
get search() { return require('./search.png'); },
get settings() { return require('./settings.png'); },
get x() { return require('./x.png'); }
get check() {
return require('./check.png');
},
get checkSmall() {
return require('./check-small.png');
},
get chevronRight() {
return require('./chevronRight.png');
},
get plusSmall() {
return require('./plusSmall.png');
},
get search() {
return require('./search.png');
},
get settings() {
return require('./settings.png');
},
get x() {
return require('./x.png');
}
};
4 changes: 3 additions & 1 deletion src/assets/images/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const images = {
get gradient() { return require('./gradient.png'); },
get gradient() {
return require('./gradient.png');
}
};
14 changes: 10 additions & 4 deletions src/assets/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Assets } from './Assets';
import {Assets} from './Assets';

export default new Assets().loadAssetsGroup('', {
get icons() { return require('./icons').icons; },
get emojis() { return require('./emojis').emojis; },
get images() { return require('./images').images; },
get icons() {
return require('./icons').icons;
},
get emojis() {
return require('./emojis').emojis;
},
get images() {
return require('./images').images;
}
});
24 changes: 12 additions & 12 deletions src/commons/SelectableComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Assets from '../assets';

const INDICATOR_TYPES = {
CIRCLE: 'circle',
CLEAN: 'clean',
CLEAN: 'clean'
};

const BaseComponent = baseComponent(false);
Expand All @@ -35,13 +35,13 @@ export default class SelectableComponent extends BaseComponent {
/**
* color of selectable indicator
*/
selectableIndicatorColor: PropTypes.string,
selectableIndicatorColor: PropTypes.string
};

static defaultProps = {
selectableIndicatorSize: 36,
selectableIndicatorType: INDICATOR_TYPES.CIRCLE,
selectableIndicatorColor: Colors.blue30,
selectableIndicatorColor: Colors.blue30
};

static indicatorTypes = INDICATOR_TYPES;
Expand All @@ -50,7 +50,7 @@ export default class SelectableComponent extends BaseComponent {
super(props);

this.state = {
selected: props.selected,
selected: props.selected
};

this.onSelect = this.onSelect.bind(this);
Expand All @@ -59,7 +59,7 @@ export default class SelectableComponent extends BaseComponent {
UNSAFE_componentWillReceiveProps(newProps) {
if (newProps.selected !== this.state.selected) {
this.setState({
selected: newProps.selected,
selected: newProps.selected
});
}
}
Expand Down Expand Up @@ -98,15 +98,15 @@ export default class SelectableComponent extends BaseComponent {
if (selectable) {
return (
<View style={this.getIndicatorContainerStyle()}>
{selected && <Image style={this.getIndicatorIconStyle()} source={Assets.icons.check} />}
{selected && <Image style={this.getIndicatorIconStyle()} source={Assets.icons.check}/>}
</View>
);
}
}

onSelect() {
this.setState({
selected: !this.state.selected,
selected: !this.state.selected
});
_.invoke(this.props, 'onPress');
}
Expand All @@ -118,19 +118,19 @@ function createStyles({selectableIndicatorSize}) {
width: selectableIndicatorSize,
height: selectableIndicatorSize,
justifyContent: 'center',
borderRadius: BorderRadiuses.br100,
borderRadius: BorderRadiuses.br100
},
circleContainer: {
borderWidth: 1,
borderColor: Colors.blue30,
borderColor: Colors.blue30
},
checkIcon: {
alignSelf: 'center',
resizeMode: 'contain',
resizeMode: 'contain'
},
checkIconInCircle: {
width: selectableIndicatorSize / 2,
tintColor: Colors.white,
},
tintColor: Colors.white
}
});
}
Loading

0 comments on commit 99c9efd

Please sign in to comment.