Skip to content

Commit

Permalink
refactor: Use eslint instead of semistandard (shootismoke#72)
Browse files Browse the repository at this point in the history
* Add eslint

* Run eslint on files

* Update contributing guide

* Update README

* Typo
  • Loading branch information
amaury1093 authored and lucienbl committed Jun 19, 2019
1 parent 319d2a2 commit 98c7e4b
Show file tree
Hide file tree
Showing 21 changed files with 864 additions and 447 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = null
28 changes: 28 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"env": {
"node": true,
"es6": true,
"jest": true
},
"extends": [
"prettier",
"prettier/standard",
"semistandard"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"legacyDecorators": true
}
},
"plugins": [
"import",
"prettier",
"react",
"standard"
],
"rules": {
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1
}
}
4 changes: 2 additions & 2 deletions App/Screens/About/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Constants } from 'expo';
import { Linking, ScrollView, StyleSheet, Text, View } from 'react-native';

import { Box } from './Box';
import * as theme from '../../utils/theme';
import { BackButton } from '../../components/BackButton';
import {i18n} from '../../localization';
import { i18n } from '../../localization';
import * as theme from '../../utils/theme';

export class About extends PureComponent {
handleOpenAmaury = () => Linking.openURL('https://twitter.com/amaurymartiny');
Expand Down
8 changes: 4 additions & 4 deletions App/Screens/Details/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { MapView } from 'expo';
import { StyleSheet, View } from 'react-native';
import truncate from 'truncate';

import { Distance } from './Distance';
import { getCorrectLatLng } from '../../utils/getCorrectLatLng';
import { Header } from './Header';
import homeIcon from '../../../assets/images/home.png';
import stationIcon from '../../../assets/images/station.png';
import { Distance } from './Distance';
import { Header } from './Header';
import { i18n } from '../../localization';
import { getCorrectLatLng } from '../../utils/getCorrectLatLng';
import * as theme from '../../utils/theme';
import {i18n} from '../../localization';

@inject('stores')
@observer
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Details/Distance/Distance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { inject, observer } from 'mobx-react';
import { StyleSheet, Text } from 'react-native';

import { Banner } from '../../../components/Banner';
import { i18n } from '../../../localization';
import * as theme from '../../../utils/theme';
import {i18n} from '../../../localization';

@inject('stores')
@observer
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/Details/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { formatRelative } from 'date-fns';
import { Image, StyleSheet, Text, View } from 'react-native';
import { inject, observer } from 'mobx-react';

import { BackButton } from '../../../components/BackButton';
import locationIcon from '../../../../assets/images/location.png';
import { BackButton } from '../../../components/BackButton';
import { CurrentLocation } from '../../../components/CurrentLocation';
import { i18n } from '../../../localization';
import * as theme from '../../../utils/theme';
import {i18n} from '../../../localization';

const trackedPollutant = ['pm25', 'pm10', 'co', 'o3', 'no2', 'so2'];

Expand Down
2 changes: 1 addition & 1 deletion App/Screens/ErrorScreen/ErrorScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React, { Component } from 'react';
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';

import error from '../../../assets/images/error.png';
import * as theme from '../../utils/theme';
import { i18n } from '../../localization';
import * as theme from '../../utils/theme';

@inject('stores')
@observer
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/Home/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { inject, observer } from 'mobx-react';
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';

import changeLocation from '../../../../assets/images/changeLocation.png';
import warning from '../../../../assets/images/warning.png';
import { CurrentLocation } from '../../../components/CurrentLocation';
import { i18n } from '../../../localization';
import * as theme from '../../../utils/theme';
import warning from '../../../../assets/images/warning.png';
import {i18n} from '../../../localization';

@inject('stores')
@observer
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {

import { Cigarettes } from './Cigarettes';
import { Header } from './Header';
import { i18n } from '../../localization';
import { SmallButton } from './SmallButton';
import { SmokeVideo } from './SmokeVideo';
import swearWords from './swearWords';
import * as theme from '../../utils/theme';
import {i18n} from '../../localization';

@inject('stores')
@observer
Expand Down
3 changes: 3 additions & 0 deletions App/Screens/Home/swearWords.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2018-2019, Amaury Martiny
// SPDX-License-Identifier: GPL-3.0

import { i18n } from '../../localization';

export default [
Expand Down
7 changes: 3 additions & 4 deletions App/Screens/Loading/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {inject, observer} from 'mobx-react';
import {Location, Permissions, TaskManager} from 'expo';
import retry from 'async-retry';
import {StyleSheet, Text} from 'react-native';

import {Background} from './Background';
import * as dataSources from '../../utils/dataSources';
import * as theme from '../../utils/theme';
Expand Down Expand Up @@ -142,9 +141,9 @@ export class Loading extends Component {
} = this.props;
const { longWaiting } = this.state;
let coughs = 0; // Number of times to show "Cough..."
if (gps) ++coughs;
if (longWaiting) ++coughs;
if (api) ++coughs;
if (gps)++coughs;
if (longWaiting)++coughs;
if (api)++coughs;

return (
<Text>
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { inject, observer } from 'mobx-react';
import retry from 'async-retry';

import { BackButton } from '../../components/BackButton';
import { SearchHeader } from './SearchHeader';
import { Item } from './Item';
import { SearchHeader } from './SearchHeader';
import * as theme from '../../utils/theme';

// As per https://community.algolia.com/places/rest.html
Expand Down
10 changes: 5 additions & 5 deletions App/Screens/Search/SearchHeader/SearchHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
import React, { PureComponent } from 'react';
import { Image, StyleSheet, TextInput } from 'react-native';

import { Banner } from '../../../components/Banner';
import searchIcon from '../../../../assets/images/search.png';
import { Banner } from '../../../components/Banner';
import { i18n } from '../../../localization';
import * as theme from '../../../utils/theme';
import {i18n} from '../../../localization';

export class SearchHeader extends PureComponent {
render () {
const { onChangeSearch, search } = this.props;
return (
<Banner elevated shadowPosition='bottom'>
<Banner elevated shadowPosition="bottom">
<TextInput
autoFocus
onChangeText={onChangeSearch}
placeholder={i18n.t('search_header_input_placeholder')}
placeholderTextColor='rgba(255, 255, 255, 0.6)'
placeholderTextColor="rgba(255, 255, 255, 0.6)"
style={styles.input}
underlineColorAndroid='transparent'
underlineColorAndroid="transparent"
value={search}
/>
<Image source={searchIcon} />
Expand Down
2 changes: 1 addition & 1 deletion App/components/BackButton/BackButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';

import backIcon from '../../../assets/images/back.png';
import * as theme from '../../utils/theme';
import {i18n} from '../../localization';
import { i18n } from '../../localization';

export class BackButton extends PureComponent {
onClick = () => this.props.onClick();
Expand Down
3 changes: 3 additions & 0 deletions App/localization/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2018-2019, Amaury Martiny
// SPDX-License-Identifier: GPL-3.0

import { Localization } from 'expo';
import i18n from 'i18n-js';

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ People _love_ thorough bug reports. I'm not even kidding.

## Use a Consistent Coding Style

The code style adheres to [semistandard](https://github.com/Flet/semistandard), and that is the only requirement. Run `yarn lint` to make sure the code you wrote passes linting.
The code style adheres to [semistandard](https://github.com/Flet/semistandard). We use an opiniated `eslint`, which is configured to behave like `prettier` + `semistandard`.

We also recommend adding the [prettier](https://github.com/prettier/prettier) extension to your IDE, though it is not mandatory.
Run `yarn lint` to make sure that your code passes linting. You can optionally add the `--fix` flag to let `eslint` automatically fix some errors.

## License

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ If you find a bug, or if you have an idea for this app, please file an issue [he

More information on contributing [here](./CONTRIBUTING.md).

## :microscope: Tests

The codebase unfortunately isn't much covered by tests. Check out the `*.spec.js` files in the project for tests. If you're interested to help out, have a look at [#19](https://github.com/amaurymartiny/shoot-i-smoke/issues/19).

## :newspaper: License

GPL-3.0. See [LICENSE](./LICENSE) file for more information.
Expand Down
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo']
};
};
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"lint": "semistandard 'App/**/*.js' --parser babel-eslint",
"lint": "eslint 'App/**/*.js'",
"start": "expo start",
"test": "jest"
},
Expand All @@ -31,8 +31,18 @@
"truncate": "^2.0.1"
},
"devDependencies": {
"babel-eslint": "^8.2.6",
"jest": "^24.5.0",
"semistandard": "^12.0.1"
"babel-eslint": "^10.0.1",
"babel-preset-expo": "^5.1.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-standard": "^4.0.0",
"jest": "^24.5.0"
}
}
Loading

0 comments on commit 98c7e4b

Please sign in to comment.