Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Refactor to ES6 #29

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"browser": true,
"es6": true,
"node": true
},
"ecmaFeatures": {
"destructuring": true,
"modules": true
},
"rules": {
"eol-last": ["error", "always"],
"indent": ["error", 4, {"SwitchCase": 1}],
"no-console": ["error"],
"no-const-assign": ["error"],
"no-tabs": ["error"],
"no-trailing-spaces": ["error"],
"no-unused-vars": ["error", {"vars": "all", "args": "none"}],
"no-var": ["error"],
"prefer-const": ["error"],
"semi": ["error", "never"],
"template-curly-spacing": ["error", "always"]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/gh-pages
/dist
/build
/hwcrypto.js
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: node_js
node_js: 6

node_js:
- "6.1"

install:
- npm install
Expand Down
54 changes: 42 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,51 @@ module.exports = function(grunt) {
}
}
},
jshint: {
src: {
src: ['src/hwcrypto.js', 'test/*.js'],
},
release: {
src: ['hwcrypto.js']
eslint: {
src: ['src/**/*.js']
},
webpack: {
build: {
entry: './src/hwcrypto.js',
output: {
path: './',
filename: 'hwcrypto.js',
library: 'hwcrypto'
},
module: {
loaders: [
{
test: /.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
}
},
includereplace: {
build: {
options: {
processIncludeContents: false,
globals: {
hwcryptoversion: '<%= pkg.version %>'
}
},
files: [
{src: 'hwcrypto.js', dest: 'build/', expand: true, cwd: 'src'}
{src: 'hwcrypto.js', dest: './', expand: true, _comment: 'Perform replace in place'},
{src: 'hwcrypto.js', dest: 'build/', expand: true, _comment: 'Use the same module lazy way for copying'}
]
},
dist: {
options: {
prefix: '<!-- @@',
suffix: ' -->',
includesDir: 'snippets/'
includesDir: 'snippets/',
globals: {
hwcryptoversion: '<%= pkg.version %>'
}
},
files: [
{src: 'sign.html', dest: 'dist/', expand: true, cwd: 'demo'},
Expand All @@ -74,6 +95,8 @@ module.exports = function(grunt) {
test: {
src: ['dist/api.html'],
options: {
ui: 'bdd',
log: true,
run: true,
},
},
Expand All @@ -94,12 +117,17 @@ module.exports = function(grunt) {
css_dest: 'dist/css'
}
},
"bower-install-simple": {
dist: {}
},
clean: ['build', 'dist']
});
// Minification
grunt.loadNpmTasks('grunt-contrib-uglify');
// code check
grunt.loadNpmTasks('grunt-contrib-jshint');
// eslint
grunt.loadNpmTasks("gruntify-eslint");
// ES6 => browser compaitble ES5
grunt.loadNpmTasks('grunt-webpack');
// development server
grunt.loadNpmTasks('grunt-contrib-connect');
// testing
Expand All @@ -108,14 +136,16 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-sync-pkg');
// file templates
grunt.loadNpmTasks('grunt-include-replace');
// perform bower install
grunt.loadNpmTasks('grunt-bower-install-simple');
// copy bower components
grunt.loadNpmTasks('grunt-bower');
// Clean up
grunt.loadNpmTasks('grunt-contrib-clean');

// Default task(s).
grunt.registerTask('build', ['clean', 'jshint:src', 'includereplace', 'uglify:minify', 'uglify:beautify']);
grunt.registerTask('dist', ['sync', 'build', 'bower', 'uglify:legacy']);
grunt.registerTask('build', ['clean', 'webpack', 'includereplace', 'uglify:minify', 'uglify:beautify']);
grunt.registerTask('dist', ['eslint', 'sync', 'build', 'bower-install-simple', 'bower', 'uglify:legacy']);
grunt.registerTask('default', ['dist', 'mocha']);
grunt.registerTask('release', ['sync', 'build', 'includereplace:build', 'uglify:release', 'jshint:release'])
};
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ For background information about the project and the eID web task force, please
For any bugs in the JavaScript component, please open an issue on Github.

## ChangeLog
- 0.0.11
- Refactored `src` to use ES6 instead of ES5. ES6 is transpiled to ES5 for distribution
- Started using `eslint` instead of `jshint`
- 0.0.9
- Have only typed arrays and promises in the legacy helper
- 0.0.8
Expand Down
8 changes: 5 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"main": [
"hwcrypto.js"
],
"version": "0.0.10",
"version": "0.0.11",
"authors": [
"Martin Paljak <martin@martinpaljak.net>"
"Martin Paljak <martin@martinpaljak.net>",
"Kaarel Raspel <kaarel.raspel@gmail.com>"
],
"description": "Polyfill for window.hwcrypto for signing with smart card extensions",
"moduleType": [
Expand Down Expand Up @@ -33,7 +34,8 @@
"jquery": "^3.1.1",
"should": "^11.1.2",
"chai-as-promised": "~4.3.0",
"bind-polyfill": "^1.0.0"
"bind-polyfill": "~1.0.0",
"promise-polyfill": "2.1.0"
},
"dependencies": {
"native-promise-only": "~0.7.6-a",
Expand Down
Loading