-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to TypeScript #9
Merged
Merged
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
26ec536
Initial configuration
600dc8d
Migrate core lib to typescript
98773bc
Separate prettier config, standardise on trailing
367a1b3
Correct module naming
4cd0220
Tidy package
7f1301a
Code style
edfbaba
Remove unnecessary return type
5fe08ff
Remove react-app-polyfill, minor change to example text
9dd0d73
Remove eslint dups, straight eslint eject via tsdx
93051b1
Remove update on resizeStop
42084e1
Add mount test in example
46c86fa
Remove react-app-polyfill from example
ed9ab8e
Upgrade to prettier 2
42b21d3
Update docs
a1f70a1
Stricter type checks, extract to utils with tests
74bcaff
Cover error case
ab6388f
Rework errors to prevent attempted never in string
054c269
Minor test name adjust
03b0366
Minor version as peer dependency
e50975e
Minimum Node 12
0c49389
Require tests
9c21ca0
eslint: explicit react setting
b76f3d1
Stricter on non-null-assertion
55d73c6
Revert to node 10 support
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,18 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
}, | ||
extends: [ | ||
'standard', | ||
'standard-react', | ||
'prettier/react', | ||
'react-app', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended', | ||
], | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['prettier', 'react', 'react-hooks'], | ||
plugins: ['react-hooks'], | ||
rules: { | ||
'react/prop-types': 'warn', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/exhaustive-deps': 'error', | ||
'import/no-unresolved': [ | ||
andy-hook marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'error', | ||
{ ignore: ['^react(-dom)?$', '^styled-components$'] }, | ||
], | ||
'promise/no-nesting': ['off'], | ||
'linebreak-style': ['error', 'unix'], | ||
curly: 'error', | ||
}, | ||
settings: { | ||
react: { | ||
pragma: 'React', | ||
version: '16.6', | ||
version: 'detect', | ||
andy-hook marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['**/*.test.js'], | ||
env: { jest: true }, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<title>Simple Viewport</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="./index.js"></script> | ||
|
||
<body style="margin: 0;"> | ||
<div id="root"></div> | ||
<script src="./index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
{ | ||
"scripts": { | ||
"start": "parcel serve index.html", | ||
"start": "parcel index.html", | ||
"build": "parcel build index.html" | ||
}, | ||
"dependencies": { | ||
"babel-polyfill": "^6.26.0", | ||
"react": "^16.12.0", | ||
"react-dom": "^16.12.0", | ||
"react": "^16.13.1", | ||
"react-app-polyfill": "^1.0.6", | ||
"react-dom": "^16.13.1", | ||
"use-viewport": "link:../.." | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.3", | ||
"parcel": "^1.12.4" | ||
"@types/react": "^16.9.49", | ||
"@types/react-dom": "^16.9.8", | ||
"parcel": "^1.12.3", | ||
"typescript": "^3.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"target": "es5", | ||
"module": "commonjs", | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"noImplicitAny": false, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"removeComments": true, | ||
"strictNullChecks": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"lib": ["es2015", "es2016", "dom"], | ||
"types": ["node"], | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the ejected defaults via
yarn lint --write-file
so I could use the hooks plugin. Do we want to be explicit here with our own standards?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I've never looked, but do you know if there a good way to diff between different eslint configs?
Since we're currently in a reset phase, this may also be a good time to standardize an eslint config for JS and TS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this and I really like the idea of standardising around a single opinionated tool. The more of this configuration we can offload the more we can focus on the building, so for the TS projects I was thinking we could just straight up use the provided values and leave it there, see how we get on?
These customisations I made were actually unnecessary, the tool ships with all the setting we would want, my editor just couldn't see the configuration.
I followed their suggested fix jaredpalmer/tsdx#379 (comment) and exported unedited default settings in 9dd0d73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so VSC can't automatically resolve TSDX's default config without ejecting them?
I've been procrastinating on setting up "standard" linting configs in https://github.com/aragon/github for forever, but now is a good chance. I'll get a structure going—I was mainly thinking of packaging something like
eslint-config-aragon-ts-react
(and etc. for other environments).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a package for our config would be lovely! And yeah, for some reason VSCode sometimes has a hard time reading configs with TSDX 😅