Skip to content

Commit a86dbf8

Browse files
authoredNov 4, 2019
[tools] Create the eslint-config package (#102)
* Add eslint-config package * Add eslintignore and config file * Update dependencies * Set rimraf and babel to specific versions * Update babel package to use latest configs * Fix lint issues * Remove explicit babel-preset 3.0.0 in package.json * Update babel dependencies * Use same version of the babel core module * Add babel-runtime for jest-plugins issues * Resolve the react-test-renderer to 16.8.3
1 parent c5dfb61 commit a86dbf8

File tree

18 files changed

+2550
-2617
lines changed

18 files changed

+2550
-2617
lines changed
 

‎.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
coverage
3+
node_modules

‎.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: '@react-x',
3+
};

‎components/primitives/src/__tests__/Primitives.spec.dom.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Modules
22
import React from 'react';
3-
import {View, Text, Image, Touchable, StyleSheet, Animated} from '../Primitives';
3+
import {View, Text, Image, Touchable} from '../Primitives';
44

55
/* eslint-disable no-undef */
66
describe('Primitives', () => {

‎components/primitives/src/__tests__/Primitives.spec.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Modules
22
import React from 'react';
3-
import {View, Text, Image, Touchable, StyleSheet, Animated} from '../Primitives';
3+
import {View, Text, Image, Touchable} from '../Primitives';
44

55
/* eslint-disable no-undef */
66
describe('Primitives', () => {

‎components/switch/src/SwitchX.dom.js

-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ const SwitchX = (props) => (
1818
SwitchX.propTypes = {
1919
onTintColor: PropTypes.string.isRequired,
2020
isOn: PropTypes.bool.isRequired,
21-
isDisabled: PropTypes.bool.isRequired,
2221
onChange: PropTypes.func,
23-
tintColor: PropTypes.string,
24-
thumbTintColor: PropTypes.string,
2522
};
2623

2724
SwitchX.defaultProps = {
2825
onChange: null,
29-
tintColor: null,
30-
thumbTintColor: null,
3126
};
3227

3328

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// React X
22
// NOTE(mark): Until we need custom functionality, we should assume react-native
33
// and react-native-web export a consistent TextInput.
4-
export default from './TextInputX';
4+
export {default} from './TextInputX';

‎modules/clipboard/src/Clipboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from './ClipboardX';
1+
export {default} from './ClipboardX';

‎modules/keychain/src/Keychain.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import KeychainX from './KeychainX';
1010
* Persistent secure storage for all apps.
1111
*/
1212
class Keychain {
13-
1413
// --------------------------------------------------
1514
// Initialize
1615
// --------------------------------------------------
@@ -48,10 +47,7 @@ class Keychain {
4847
// Private
4948
// --------------------------------------------------
5049
assertInitialized(method) {
51-
invariant(
52-
this.initialized,
53-
`Keychain calling '${method}' before it has been initialized.`,
54-
);
50+
invariant(this.initialized, 'Keychain calling method before it has been initialized.');
5551
}
5652

5753
async setEntries(entries = {}) {
@@ -76,7 +72,6 @@ class Keychain {
7672
this.all = omit(this.all, keys);
7773
return this.keychain.clearKeys(keys, this.all, this.options);
7874
}
79-
8075
}
8176

8277

‎modules/keychain/src/KeychainX.dom.js

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Cookies from 'cookies-js';
66
* Persistent secure storage for the web. Wrapper around Cookies for the web.
77
*/
88
class KeychainX {
9-
109
async getEntries(keys = []) {
1110
const accumulate = (all, key) => {
1211
all[key] = Cookies.get(key);
@@ -25,7 +24,6 @@ class KeychainX {
2524
async clearKeys(keys = [], all = {}, options = {}) {
2625
return keys.map((key) => Cookies.expire(key, options));
2726
}
28-
2927
}
3028

3129

‎modules/keychain/src/KeychainX.native.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Libraries
22
import * as RNKeychain from 'react-native-keychain';
3-
import omit from 'lodash.omit';
43
import pick from 'lodash.pick';
54

65

@@ -9,7 +8,6 @@ import pick from 'lodash.pick';
98
* native keychain module on iOS and shared preferences on Android.
109
*/
1110
class KeychainX {
12-
1311
constructor({namespace}) {
1412
this.namespace = namespace;
1513
}
@@ -18,7 +16,7 @@ class KeychainX {
1816
try {
1917
// We store all key/values in the password field.
2018
const data = await RNKeychain.getGenericPassword(this.namespace);
21-
const {username, password} = data;
19+
const {password} = data;
2220
const all = JSON.parse(password);
2321

2422
// Only return the key / values for the keys we specified.
@@ -49,7 +47,6 @@ class KeychainX {
4947
// Set the remaining values on the keychain again.
5048
return this.save(all);
5149
}
52-
5350
}
5451

5552

‎modules/keychain/src/__tests__/Keychain.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ describe('Keychain', () => {
8080
context('with keys in all', () => {
8181
set('key', () => 'test');
8282
set('all', () => ({test: 'value'}));
83-
beforeEach(() => keychain.all = all);
83+
beforeEach(() => {
84+
keychain.all = all;
85+
});
8486

8587
it('should return the value', () => {
8688
expect(get()).toEqual('value');

‎package.json

+8-17
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,22 @@
66
"yarn": ">=1.0.1"
77
},
88
"devDependencies": {
9-
"@babel/core": "^7.4.4",
10-
"@react-x/babel-preset": "3.0.0",
11-
"coveralls": "^2.13.1",
12-
"eslint": "^4.4.1",
13-
"eslint-config-jolt": "^2.6.1",
14-
"eslint-plugin-jest": "^21.0.2",
15-
"husky": "^0.14.3",
16-
"jest": "^24.8.0",
9+
"@babel/core": "7.6.2",
10+
"coveralls": "3.0.7",
11+
"husky": "0.14.3",
12+
"jest": "24.8.0",
1713
"lerna": "3.18.3",
18-
"lint-staged": "^4.0.3",
14+
"lint-staged": "4.0.3",
1915
"react": "16.8.3",
2016
"react-art": "16.8.3",
2117
"react-dom": "16.8.3",
2218
"react-native": "0.59.8",
2319
"react-native-web": "0.11.4",
24-
"rimraf": "^2.6.1"
20+
"rimraf": "2.6.1"
2521
},
26-
"eslintConfig": {
27-
"extends": "jolt"
22+
"resolutions": {
23+
"react-test-renderer": "16.8.3"
2824
},
29-
"eslintIgnore": [
30-
"build",
31-
"coverage",
32-
"node_modules"
33-
],
3425
"jest": {
3526
"projects": [
3627
"test/jest-config.dom.js",

‎packages/react-x/src/__tests__/react-x.spec.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Modules
2-
import React from 'react';
32
import ReactX from '../react-x';
43

54
/* eslint-disable no-undef */

‎tools/babel-preset/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module.exports = () => {
1+
module.exports = (context, options = {}) => {
22
return {
33
presets: [
44
'@babel/preset-env',
55
'@babel/preset-react',
66
],
77
plugins: [
8-
'@babel/plugin-proposal-export-default-from',
8+
'@babel/plugin-proposal-class-properties',
99
'@babel/plugin-transform-flow-strip-types',
1010
'@babel/plugin-transform-runtime',
1111
],

‎tools/babel-preset/package.json

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"name": "@react-x/babel-preset",
33
"version": "3.1.0",
4+
"dependencies": {
5+
"@babel/runtime": "7.5.5"
6+
},
47
"devDependencies": {
5-
"@babel/cli": "^7.4.4",
6-
"@babel/core": "^7.4.4",
7-
"@babel/plugin-proposal-export-default-from": "^7.2.0",
8-
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
9-
"@babel/plugin-transform-runtime": "^7.4.4",
10-
"@babel/preset-env": "^7.4.4",
11-
"@babel/preset-react": "^7.0.0",
12-
"@babel/runtime": "^7.4.4",
13-
"babel-jest": "^24.8.0"
8+
"@babel/cli": "7.6.2",
9+
"@babel/core": "7.6.2",
10+
"@babel/plugin-proposal-class-properties": "7.5.5",
11+
"@babel/plugin-transform-flow-strip-types": "7.6.3",
12+
"@babel/plugin-transform-runtime": "7.6.2",
13+
"@babel/preset-env": "7.6.2",
14+
"@babel/preset-react": "7.0.0",
15+
"babel-runtime": "6.26.0"
1416
},
1517
"scripts": {}
1618
}

‎tools/eslint-config/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@react-x/eslint-config",
3+
"version": "3.1.0",
4+
"main": "src/eslintrc.js",
5+
"dependencies": {
6+
"@typescript-eslint/eslint-plugin": "1.13.0",
7+
"@typescript-eslint/parser": "1.13.0",
8+
"babel-eslint": "10.0.3",
9+
"eslint": "5.16.0",
10+
"eslint-config-airbnb": "18.0.1",
11+
"eslint-config-react-app": "4.0.1",
12+
"eslint-plugin-flowtype": "2.50.3",
13+
"eslint-plugin-import": "2.18.2",
14+
"eslint-plugin-jsx-a11y": "6.2.3",
15+
"eslint-plugin-react": "7.16.0",
16+
"eslint-plugin-react-hooks": "1.7.0",
17+
"typescript": "3.6.4"
18+
}
19+
}

‎tools/eslint-config/src/eslintrc.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module.exports = {
2+
extends: [
3+
'airbnb',
4+
'react-app',
5+
],
6+
rules: {
7+
'indent': [2, 2, {SwitchCase: 1}],
8+
'no-unused-vars': 2,
9+
'object-curly-newline': [2, {multiline: true, consistent: true}],
10+
'object-curly-spacing': [2, 'never'],
11+
'operator-linebreak': [2, 'after'],
12+
'quote-props': [2, 'consistent-as-needed'],
13+
'react/jsx-closing-bracket-location': [2, 'tag-aligned'],
14+
'max-len': [2, 100],
15+
16+
// TODO(mark): These should be turned on but requires a larger change.
17+
'arrow-body-style': 0,
18+
'arrow-parens': 0,
19+
'consistent-return': 0,
20+
'global-require': 0,
21+
'no-console': 0,
22+
'no-confusing-arrow': 0,
23+
'no-else-return': 0,
24+
'no-nested-ternary': 0,
25+
'no-param-reassign': 0,
26+
'no-shadow': 0,
27+
'no-useless-return': 0,
28+
'quotes': 0,
29+
'import/no-extraneous-dependencies': 0,
30+
'import/no-unresolved': 0,
31+
'react/forbid-prop-types': 0,
32+
'react/prop-types': 0,
33+
34+
// TODO(mark): These rules have issues with the shared/<package> packages.
35+
'class-methods-use-this': 0,
36+
'no-underscore-dangle': 0,
37+
'react/destructuring-assignment': 0,
38+
'react/no-find-dom-node': 0,
39+
'react/no-string-refs': 0,
40+
'react/no-unused-state': 0,
41+
'react/sort-comp': 0,
42+
'react/state-in-constructor': 0,
43+
44+
// TODO(mark): Need to double check if we want these off or not.
45+
'import/prefer-default-export': 0,
46+
'react/jsx-curly-brace-presence': 0,
47+
'react/jsx-filename-extension': 0,
48+
'react/jsx-fragments': 0,
49+
'react/jsx-props-no-spreading': 0,
50+
'react/no-array-index-key': 0,
51+
'react/no-children-prop': 0,
52+
'react/no-unescaped-entities': 0,
53+
},
54+
};

‎yarn.lock

+2,441-2,566
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.