Skip to content

Commit 3299e3a

Browse files
authored
small fix for better dev experience (#49)
* small fix for better dev experience * Add CI builds back * add eslint
1 parent bed8c52 commit 3299e3a

36 files changed

+893
-576
lines changed

.changeset/234a1cb2/changes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "releases": [{ "name": "extract-react-types-loader", "type": "patch" }], "dependents": [] }

.changeset/234a1cb2/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix the dev mode data to align with new structure for ERT 0.15, as previously no render was occurring

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated files
2+
dist/
3+
node_modules/
4+
flow-typed/

.eslintrc.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module.exports = {
2+
extends: [
3+
'prettier',
4+
'airbnb',
5+
'prettier/react',
6+
'plugin:jest/recommended',
7+
'plugin:prettier/recommended'
8+
],
9+
parser: 'babel-eslint',
10+
plugins: ['prettier', 'react', 'import', 'jest'],
11+
env: {
12+
es6: true,
13+
browser: true,
14+
node: true,
15+
'jest/globals': true
16+
},
17+
globals: {
18+
// flow globals
19+
TimeoutID: true,
20+
IntervalID: true,
21+
AnimationFrameID: true
22+
},
23+
rules: {
24+
// Error on prettier violations
25+
'prettier/prettier': 'error',
26+
27+
'prefer-const': 'off',
28+
29+
// New eslint style rules that is not disabled by prettier:
30+
'lines-between-class-members': 'off',
31+
32+
// Allowing warning and error console logging
33+
// use `invariant` and `warning`
34+
'no-console': ['error'],
35+
36+
// Opting out of prefer destructuring (nicer with flow in lots of cases)
37+
'prefer-destructuring': 'off',
38+
39+
// Disallowing the use of variables starting with `_` unless it called on `this`.
40+
// Allowed: `this._secret = Symbol()`
41+
// Not allowed: `const _secret = Symbol()`
42+
'no-underscore-dangle': ['error', { allowAfterThis: true }],
43+
44+
// Cannot reassign function parameters but allowing modification
45+
'no-param-reassign': ['error', { props: false }],
46+
47+
// Allowing ++ on numbers
48+
'no-plusplus': 'off',
49+
50+
// Allowing Math.pow rather than forcing `**`
51+
'no-restricted-properties': [
52+
'off',
53+
{
54+
object: 'Math',
55+
property: 'pow'
56+
}
57+
],
58+
59+
// Allowing jsx in files with any file extension (old components have jsx but not the extension)
60+
'react/jsx-filename-extension': 'off',
61+
62+
// Not requiring default prop declarations all the time
63+
'react/require-default-props': 'off',
64+
65+
// Opt out of preferring stateless functions
66+
'react/prefer-stateless-function': 'off',
67+
68+
// Allowing files to have multiple components in it
69+
'react/no-multi-comp': 'off',
70+
71+
// Sometimes we use the PropTypes.object PropType for simplicity
72+
'react/forbid-prop-types': 'off',
73+
74+
// Allowing the non function setState approach
75+
'react/no-access-state-in-setstate': 'off',
76+
77+
// Opting out of this
78+
'react/destructuring-assignment': 'off',
79+
80+
// Adding 'skipShapeProps' as the rule has issues with correctly handling PropTypes.shape
81+
'react/no-unused-prop-types': ['error', { skipShapeProps: true }],
82+
83+
// Having issues with this rule not working correctly
84+
'react/default-props-match-prop-types': 'off',
85+
86+
// Allowing importing from dev deps (for stories and tests)
87+
'import/no-extraneous-dependencies': 'off',
88+
'spaced-comment': 'off',
89+
'consistent-return': 'off',
90+
'no-else-return': 'off',
91+
'react/jsx-curly-brace-presence': 'off',
92+
'import/no-useless-path-segments': 'off',
93+
'react/sort-comp': 'off',
94+
'no-use-before-define': 'off',
95+
'no-restricted-syntax': 'off'
96+
}
97+
};

packages/extract-react-types/.travis.yml renamed to .travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_js:
44
- '8'
55
cache: yarn
66
script: |
7+
yarn bolt
78
yarn flow check
89
if [[ $? != 0 ]]; then exit 1; fi
910
yarn test

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Ben Conolly
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"name": "extract-react-types-mono-repo",
33
"version": "0.0.0",
4+
"license": "MIT",
45
"scripts": {
56
"test": "jest",
6-
"changeset": "bolt build-releases changeset"
7+
"changeset": "bolt build-releases changeset",
8+
"dev:pretty-proptypes": "bolt w pretty-proptypes run dev",
9+
"lint": "yarn eslint \"./**/*.js\"",
10+
"check": "yarn lint && yarn test && yarn flow"
711
},
812
"bolt": {
913
"workspaces": [
@@ -16,6 +20,7 @@
1620
"@babel/types": "^7.0.0-beta.56",
1721
"ast-pretty-print": "^2.0.1",
1822
"babel-errors": "^1.1.1",
23+
"babel-eslint": "^10.0.1",
1924
"babel-explode-module": "^3.0.0",
2025
"babel-file": "^3.0.0",
2126
"babel-file-loader": "^2.0.0",
@@ -28,6 +33,15 @@
2833
"babylon": "^7.0.0-beta.22",
2934
"babylon-options": "^2.0.1",
3035
"emotion": "^9.1.1",
36+
"eslint": "^5.13.0",
37+
"eslint-config-airbnb": "^17.1.0",
38+
"eslint-config-prettier": "^4.0.0",
39+
"eslint-plugin-import": "^2.16.0",
40+
"eslint-plugin-jest": "^22.2.2",
41+
"eslint-plugin-jsx-a11y": "^6.2.1",
42+
"eslint-plugin-prettier": "^3.0.1",
43+
"eslint-plugin-react": "^7.12.4",
44+
"jest-in-case": "^1.0.2",
3145
"react-markings": "^1.2.0",
3246
"strip-indent": "^2.0.0"
3347
},

packages/extract-react-types-loader/index.js

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,33 @@ const path = require('path');
44
const extractReactTypes = require('extract-react-types');
55

66
const devProps = {
7-
classes: [
8-
{
9-
value: {
10-
kind: 'object',
11-
members: [
7+
component: {
8+
kind: 'object',
9+
members: [
10+
{
11+
kind: 'property',
12+
key: { kind: 'id', name: 'Warning' },
13+
value: { kind: 'any' },
14+
optional: false,
15+
leadingComments: [
1216
{
13-
kind: 'property',
14-
key: { kind: 'id', name: 'Warning' },
15-
value: { kind: 'any' },
16-
optional: false,
17-
leadingComments: [
18-
{
19-
type: 'commentBlock',
20-
value: `extract-react-types is not being run in dev mode for speed reasons. If you need to
17+
type: 'commentBlock',
18+
value: `extract-react-types is not being run in dev mode for speed reasons. If you need to
2119
see prop types add the environment variable \`FORCE_EXTRACT_REACT_TYPES\`
2220
eg:
2321
- \`FORCE_EXTRACT_REACT_TYPES=true yarn start <packageName>\`
2422
- \`FORCE_EXTRACT_REACT_TYPES=true yarn start:<team>\``,
25-
raw: '**',
26-
},
27-
],
28-
default: {
29-
kind: 'string',
30-
value: 'Prop types are not shown in dev mode',
31-
},
32-
},
23+
raw: '**'
24+
}
3325
],
34-
referenceIdName: 'AvatarPropTypes',
35-
},
36-
},
37-
],
26+
default: {
27+
kind: 'string',
28+
value: 'Prop types are not shown in dev mode'
29+
}
30+
}
31+
],
32+
referenceIdName: 'AvatarPropTypes'
33+
}
3834
};
3935

4036
module.exports = function extractReactTypesLoader(content /* : string */) {
@@ -51,15 +47,11 @@ module.exports = function extractReactTypesLoader(content /* : string */) {
5147

5248
const resolveOpts = {
5349
pathFilter: (pkg, location, dist) => {
54-
if (
55-
pkg['atlaskit:src'] &&
56-
location.includes('node_modules') &&
57-
location.includes(pkg.main)
58-
) {
50+
if (pkg['atlaskit:src'] && location.includes('node_modules') && location.includes(pkg.main)) {
5951
return location.replace(dist, pkg['atlaskit:src']);
6052
}
6153
return null;
62-
},
54+
}
6355
};
6456

6557
const types = extractReactTypes(content, typeSystem, filename, resolveOpts);

0 commit comments

Comments
 (0)