Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Add flow type annotations. #47

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict"

module.exports = {
// Have not used webpack so just copied proposed setup from
// https://babeljs.io/docs/setup/#installation
webpack: {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
}
}
}
34 changes: 34 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"env": {
"development": {
"sourceMaps": "inline",
"comments": false,
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
],
"flow-node"
]
},
"umd": {
"comments": false,
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": "last 2 versions"
}
}
],
"flow-node"
]
}
}
}
9 changes: 9 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[ignore]
.*/node_modules/documentation/*

[libs]

[include]

[options]
suppress_comment= \\(.\\|\n\\)*\\@FlowIgnore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ node_modules

dist
docs
lib
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this file is meant to be in this PR.

"editor.formatOnSave": false,
"json.format.enable": false
}
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install:
- npm install

test_script:
- npm run build:node
- npm run test:node

build: off
34 changes: 28 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@
"name": "multihashes",
"version": "0.4.13",
"description": "multihash implementation",
"main": "src/index.js",
"main": "lib/index.js",
"scripts": {
"lint": "aegir lint",
"lint": "lint-staged && npm run type-check",
"test:browser": "aegir test --target browser",
"test:node": "aegir test --target node",
"build": "aegir build",
"test": "aegir test",
"type-check": "flow check",
"build": "npm run build:node && BABEL_ENV=umd aegir build",
"test": "npm run build:node && aegir test",
"docs": "aegir docs",
"release": "aegir release --docs",
"release-minor": "aegir release --type minor --docs",
"release-major": "aegir release --type major --docs",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls"
"coverage-publish": "aegir coverage --provider coveralls",
"build:types": "flow-copy-source --verbose src lib",
"build:lib": "babel --out-dir lib src",
"build:node": "npm run build:types && npm run build:lib",
"start": "flow-copy-source --watch --verbose src lib & babel --watch --out-dir lib src"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to also add the type checking to the npm start command? It would be nice to be warned if there are any type errors introduced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice there should be impossible to introduce type errors as that would fail In CI and there for won’t be merged.

Also given that initail run of type checking takes quite bit time I don’t think running that on start would be a good option.

},
"lint-staged": {
"*.js": [
"prettier --no-semi --write",
"git add"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had bad experiences with a lint-staged configuration like this in the past. The main problem is that when you only stage patches of a file which get changed by prettier --write afterwards the whole file is staged.

]
},
"pre-commit": [
"lint",
Expand Down Expand Up @@ -43,10 +54,21 @@
},
"devDependencies": {
"aegir": "^12.3.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-preset-flow-node": "2.0.1",
"buffer-equal": "1.0.0",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"pre-commit": "^1.2.2"
"flow-bin": "^0.66.0",
"flow-copy-source": "^1.2.0",
"lint-staged": "^6.0.0",
"pre-commit": "^1.2.2",
"prettier": "1.10.2",
"rollup": "0.56.1",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was rollup introduced / where does it get used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered the same. I'm in the process of pushing an updated version of this PR. There I don't use the rollup module and it still seems to work.

"rollup.config.flow": "1.0.0",
"source-map-support": "0.5.3"
},
"contributors": [
"Alan Shaw <alan@tableflip.io>",
Expand Down
Loading