Skip to content

Commit ef9a265

Browse files
authored
Fix: Incorrect TypeScript declarations and export format (#136)
* Do not run build step on local install, only during publish * A few more keywords while at it * moving to ts * about to setup prettier * add prettier * Update command * setup husky * Fix html * Fix html * test pretty html * Add editor config * update editor config * updated indentation rules * test indent * tweak setup with html * Implementing typescript * setup export properly * test ts on ci * cleanup * no sourcemap * wrong cli argument * typo * tweak readme
1 parent af70e79 commit ef9a265

16 files changed

+1170
-657
lines changed

.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616

1717
- run: yarn install
1818

19+
- run: yarn test
20+
1921
- save_cache:
2022
paths:
2123
- node_modules

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_size = 2
9+
indent_style = space

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
package.json

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
singleQuote: true
2+
trailingComma: es5
3+
semi: false

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ yarn add scroll-into-view-if-needed
1212

1313
## API
1414

15-
### scrollIntoViewIfNeeded(node:Element, centerIfNeeded:boolean, options:object)
15+
### scrollIntoViewIfNeeded(node:Element, centerIfNeeded:boolean, AnimateOptions:object)
1616

1717
Returns a function that can be used to cancel a scroll animation.
1818
Inspired by [scroll-iv](https://www.npmjs.com/package/scroll-iv).
@@ -24,11 +24,11 @@ Inspired by [scroll-iv](https://www.npmjs.com/package/scroll-iv).
2424
This defaults to true to match the behavior of the WebKit/Blink implementation.
2525
Set it to false to actually only scroll the parent when needed and not further than absolutely necessary.
2626

27-
##### duration
27+
##### AnimateOptions.duration
2828

2929
The duration of the animation in milliseconds, defaults to 0 for no animation.
3030

31-
##### easing
31+
##### AnimateOptions.easing
3232

3333
default is ease. Possible values: `ease|easeIn|easeOut|easeInOut|linear`
3434

package.json

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,28 @@
11
{
22
"name": "scroll-into-view-if-needed",
33
"description": "Element.scrollIntoViewIfNeeded ponyfill that can animate the scrolling",
4-
"main": "dist/index.js",
5-
"typings": "typings.d.ts",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
8-
"build": "npm run clean && npm run build-module && npm run build-bundle",
9-
"build-module": "babel src -d dist",
10-
"build-bundle": "rollup src/index.js --format cjs -c --output dist/bundle.js && rollup test/index.js -c -f umd --output test/bundle.js",
11-
"clean": "rimraf dist",
12-
"prepublish": "npm run build",
13-
"changelog:preview": "sr-changelog",
14-
"changelog:commit": "sr-changelog commit",
15-
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
16-
},
17-
"release": {
18-
"analyzeCommits": "semantic-release-tamia/analyzeCommits",
19-
"verifyConditions": "condition-circle",
20-
"generateNotes": "semantic-release-tamia/generateNotes",
21-
"verifyRelease": "semantic-release-tamia/verifyRelease"
22-
},
4+
"author": "Stian Didriksen",
5+
"license": "MIT",
236
"repository": {
247
"type": "git",
258
"url": "git+https://github.com/stipsan/scroll-into-view-if-needed.git"
269
},
27-
"keywords": [
28-
"ponyfill",
29-
"smooth",
30-
"scroll",
31-
"scroll-into-view"
32-
],
33-
"author": "Stian Didriksen",
34-
"license": "MIT",
3510
"bugs": {
3611
"url": "https://github.com/stipsan/scroll-into-view-if-needed/issues"
3712
},
38-
"homepage": "https://github.com/stipsan/scroll-into-view-if-needed#readme",
13+
"main": "dist/bundle.js",
14+
"scripts": {
15+
"build": "npm run clean && npm run build-module && npm run build-bundle",
16+
"build-bundle": "rollup -c",
17+
"build-module": "tsc",
18+
"changelog:commit": "sr-changelog commit",
19+
"changelog:preview": "sr-changelog",
20+
"clean": "rimraf dist",
21+
"precommit": "lint-staged",
22+
"prepublishOnly": "yarn build",
23+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
24+
"test": "tsc --noEmit"
25+
},
3926
"dependencies": {
4027
"amator": "1.0.1"
4128
},
@@ -44,11 +31,54 @@
4431
"babel-plugin-add-module-exports": "^0.2.1",
4532
"babel-preset-env": "^1.2.1",
4633
"babel-preset-es2015-rollup": "^3.0.0",
34+
"husky": "^0.14.3",
35+
"lint-staged": "^4.3.0",
36+
"prettier": "^1.7.4",
4737
"release-relief": "^1.0.1",
4838
"rimraf": "^2.6.1",
49-
"rollup": "^0.41.4",
39+
"rollup": "^0.50.0",
5040
"rollup-plugin-babel": "^2.7.1",
5141
"rollup-plugin-commonjs": "^8.0.2",
52-
"rollup-plugin-node-resolve": "^2.0.0"
53-
}
42+
"rollup-plugin-node-resolve": "^2.0.0",
43+
"typescript": "^2.6.1"
44+
},
45+
"keywords": [
46+
"ponyfill",
47+
"scroll",
48+
"scroll-into-view",
49+
"scrollIntoView",
50+
"scrollIntoViewIfNeeded",
51+
"smooth",
52+
"smooth"
53+
],
54+
"lint-staged": {
55+
"*.html": [
56+
"npx https://gist.github.com/stipsan/0d0578fe92bcdeb024a0af2a3e2a9e2a",
57+
"git add"
58+
],
59+
"*.js": [
60+
"prettier --write",
61+
"git add"
62+
],
63+
"*.ts": [
64+
"prettier --write",
65+
"git add"
66+
],
67+
"*.json": [
68+
"prettier --write",
69+
"git add"
70+
],
71+
"package.json": [
72+
"npx prettier-package-json --write",
73+
"git add"
74+
]
75+
},
76+
"module": "dist/index.js",
77+
"release": {
78+
"analyzeCommits": "semantic-release-tamia/analyzeCommits",
79+
"verifyConditions": "condition-circle",
80+
"generateNotes": "semantic-release-tamia/generateNotes",
81+
"verifyRelease": "semantic-release-tamia/verifyRelease"
82+
},
83+
"typings": "dist/index.d.ts"
5484
}

rollup.config.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
1-
import commonjs from 'rollup-plugin-commonjs';
2-
import nodeResolve from 'rollup-plugin-node-resolve';
1+
import commonjs from 'rollup-plugin-commonjs'
2+
import nodeResolve from 'rollup-plugin-node-resolve'
3+
const globals = {}
34

45
export default {
6+
entry: 'dist/index.js',
7+
dest: 'dist/bundle.js',
8+
format: 'umd',
9+
moduleName: 'scrollIntoViewIfNeeded',
10+
exports: 'named',
11+
globals,
12+
onwarn,
513
plugins: [
614
nodeResolve({
715
jsnext: true,
8-
main: true
16+
main: true,
917
}),
1018

1119
commonjs({
1220
// non-CommonJS modules will be ignored, but you can also
1321
// specifically include/exclude files
14-
include: 'node_modules/**', // Default: undefined
22+
include: 'node_modules/**', // Default: undefined
1523

1624
// if false then skip sourceMap generation for CommonJS modules
17-
sourceMap: false, // Default: true
18-
})
19-
]
20-
}
25+
sourceMap: false, // Default: true
26+
}),
27+
],
28+
}
29+
30+
function onwarn(message) {
31+
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED']
32+
33+
if (!suppressed.find(code => message.code === code)) {
34+
return console.warn(message.message)
35+
}
36+
}

src/index.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)