Skip to content

Commit

Permalink
Fix lint scripts to run ESLint on TS files
Browse files Browse the repository at this point in the history
- Update ESLint rules
- Allow JSON imports in TS
  • Loading branch information
OzzieOrca committed May 24, 2019
1 parent efc5177 commit fddfdc8
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .eslintrc
Expand Up @@ -44,7 +44,6 @@
"import/default": 2,
"import/newline-after-import": 2,
"no-undef": 2,
"no-unused-vars": 2,
"curly": 2,
"require-await": 2,
"prefer-const": 2,
Expand Down Expand Up @@ -83,11 +82,13 @@
"react/no-deprecated": 2,
"react/prop-types": 0,
"react/display-name": 0,
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off"
},
"settings": {
"import/resolver": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -15,8 +15,8 @@
"test:s": "npm run test:snapshot",
"ios": "react-native run-ios",
"ios:pod": "cd ios && pod install",
"lint": "eslint './*.{js,ts,tsx}' ./src",
"lint:fix": "eslint './*.{js,ts,tsx}' ./src --fix",
"lint": "eslint './*.{js,ts,tsx}' './src/**/*.{js,ts,tsx}'",
"lint:fix": "eslint './*.{js,ts,tsx}' './src/**/*.{js,ts,tsx}' --fix",
"lint:ts": "tsc",
"prettier:check": "prettier '{{src,bin,testUtils,__{tests,mocks}__}/**/*.{js,json,ts,tsx},./*.{js,json,ts,tsx,yml}}' --list-different",
"prettier:write": "prettier '{{src,bin,testUtils,__{tests,mocks}__}/**/*.{js,json,ts,tsx},./*.{js,json,ts,tsx,yml}}' --write",
Expand Down
20 changes: 11 additions & 9 deletions src/@types/react-native-default-preference/index.d.ts
@@ -1,14 +1,16 @@
declare module 'react-native-default-preference' {
function get(key: String): Promise<String>;
function set(key: String, value: String): Promise<Void>;
function clear(key: String): Promise<Void>;
function getMultiple(keys: Array<String>): Promise<Array<String>>;
function setMultiple(data: Object): Promise<Void>;
function clearMultiple(keys: Array<String>): Promise<Void>;
function getAll(): Promise<Object>;
function get(key: string): Promise<string>;
function set(key: string, value: string): Promise<Void>;
function clear(key: string): Promise<Void>;
function getMultiple(keys: string[]): Promise<string[]>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setMultiple(data: Record<string, any>): Promise<Void>;
function clearMultiple(keys: string[]): Promise<Void>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getAll(): Promise<Record<string, any>>;
function clearAll(): Promise<Void>;

/** Gets and sets the current preferences file name (android) or user default suite name (ios) **/
function getName(): Promise<String>;
function setName(name: String): Promise<Void>;
function getName(): Promise<string>;
function setName(name: string): Promise<Void>;
}
3 changes: 3 additions & 0 deletions src/App.tsx
Expand Up @@ -94,11 +94,14 @@ export default class App extends Component {
ErrorUtils.setGlobalHandler(this.handleError);
}

// eslint-disable-next-line complexity
handleError(e: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
apiError: any;
key?: string;
method?: string;
endpoint?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
query?: any;
}) {
const { apiError } = e;
Expand Down
4 changes: 2 additions & 2 deletions src/actions/analytics.js
@@ -1,5 +1,5 @@
import * as RNOmniture from 'react-native-omniture';
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Tracker, Emitter } from '@ringierag/snowplow-reactjs-native-tracker';
import Config from 'react-native-config';

Expand Down Expand Up @@ -129,7 +129,7 @@ function sendState(context) {
//sendStateToSnowplow(context);
}

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function sendStateToSnowplow(context) {
const idData = {
gr_master_person_id: context[ANALYTICS.GR_MASTER_PERSON_ID],
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/index.js
Expand Up @@ -62,7 +62,7 @@ export default class Button extends Component {
disabled,
style = {},
buttonTextStyle = {},
pressProps, // eslint-disable-line no-unused-vars
pressProps, // eslint-disable-line @typescript-eslint/no-unused-vars
...rest
} = this.props;
let content = children;
Expand Down
2 changes: 1 addition & 1 deletion src/components/IconButton/index.js
Expand Up @@ -16,7 +16,7 @@ export default class IconButton extends Component {
};
render() {
// Remove `pressProps` and `onPress` so that they aren't included in the `...rest` array
const { name, type, style = {}, onPress, pressProps, ...rest } = this.props; // eslint-disable-line no-unused-vars
const { name, type, style = {}, onPress, pressProps, ...rest } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars

return (
<Button type="transparent" {...rest} onPress={this.handlePress}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Touchable/index.android.js
Expand Up @@ -27,7 +27,7 @@ class TouchableAndroid extends Component {
isAndroidOpacity,
children,
style,
pressProps, // eslint-disable-line no-unused-vars
pressProps, // eslint-disable-line @typescript-eslint/no-unused-vars
withoutFeedback,
...rest
} = this.props;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Touchable/index.ios.js
Expand Up @@ -22,7 +22,7 @@ class TouchableIOS extends Component {
const {
highlight,
withoutFeedback,
pressProps, // eslint-disable-line no-unused-vars
pressProps, // eslint-disable-line @typescript-eslint/no-unused-vars
...rest
} = this.props;

Expand Down
4 changes: 2 additions & 2 deletions src/theme.ts
@@ -1,7 +1,7 @@
import { Dimensions, StatusBarStyle } from 'react-native';
import Color from 'color';

import { exists, isAndroid, hasNotch } from './utils/common';
import { isAndroid, hasNotch } from './utils/common';

const { width: deviceWidth, height: deviceHeight } = Dimensions.get('window');

Expand All @@ -26,7 +26,7 @@ function colorConvert({
whiten?: number;
blacken?: number;
hex?: boolean;
}) {
}): string {
let col = Color(color);
// Lots of things you can do with color stuff
if (alpha) {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -7,6 +7,7 @@
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
"resolveJsonModule": true,
"skipLibCheck": true,
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
Expand Down

0 comments on commit fddfdc8

Please sign in to comment.