Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Use ESLint to ensure uniform and modern JavaScript syntax
Browse files Browse the repository at this point in the history
js-jose's code has allowed for mixing snake camel case, varying
indentation practices etc. I'm sure this could have been addressed with
proper jshint config, but having used ESLint in the past, it seems to
make a better job at enforcing rules and also auto-fixing small mishaps.

I've picked standardjs.com as the basis for the JavaScript style, with
one omission -- unlike standardjs, js-jose will still use semicolons
everywhere (happy to change it, but seemed like a bigger change that
could happen in a separate PR).
  • Loading branch information
mbyczkowski committed Jul 1, 2019
1 parent 40df213 commit 8f065ce
Show file tree
Hide file tree
Showing 16 changed files with 1,063 additions and 1,023 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"semi": ["error", "always"]
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -5,7 +5,7 @@ forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions
and style in order to keep the code as readable as possible. Please also make
sure all tests pass by running `make test`.
sure all tests pass by running `npm run build`.

Before your code can be accepted into the project you must also sign the
Individual Contributor License Agreement. We use [cla-assistant.io][1] and you
Expand Down
28 changes: 14 additions & 14 deletions Gruntfile.js
Expand Up @@ -6,11 +6,11 @@ module.exports = function(grunt) {
var config = {
pkg: grunt.file.readJSON('package.json'),

jshint: {
all: ['Gruntfile.js', 'lib/*.js'],
eslint: {
options: {
"esversion": 6
}
fix: true
},
target: 'lib'
},

webpack: {
Expand All @@ -26,13 +26,13 @@ module.exports = function(grunt) {
},
reporters: ['coverage', 'progress'],
coverageReporter: {
type : 'lcovonly',
dir : 'coverage/'
type: 'lcovonly',
dir: 'coverage/'
},
frameworks: ['qunit'],
files: [
{pattern: 'dist/jose.js', watching: false, included: false},
{pattern: 'test/qunit-promises.js', watching: false, included: false},
{ pattern: 'dist/jose.js', watching: false, included: false },
{ pattern: 'test/qunit-promises.js', watching: false, included: false },
'test/jose-jwe-test.html',
'test/jose-jws-ecdsa-test.html',
'test/jose-jws-rsa-test.html'
Expand All @@ -46,15 +46,15 @@ module.exports = function(grunt) {
}
},
singleRun: true,
plugins:['karma-coverage', 'karma-qunit', 'karma-chrome-launcher']
plugins: ['karma-coverage', 'karma-qunit', 'karma-chrome-launcher']
}
},
without_coverage: {
options: {
frameworks: ['qunit'],
files: [
{pattern: 'dist/jose.js', watching: false, included: false},
{pattern: 'test/qunit-promises.js', watching: false, included: false},
{ pattern: 'dist/jose.js', watching: false, included: false },
{ pattern: 'test/qunit-promises.js', watching: false, included: false },
'test/jose-jwe-test.html',
'test/jose-jws-ecdsa-test.html',
'test/jose-jws-rsa-test.html'
Expand Down Expand Up @@ -90,12 +90,12 @@ module.exports = function(grunt) {
grunt.initConfig(config);

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-karma-coveralls');
grunt.loadNpmTasks('grunt-webpack');

grunt.registerTask('default', ['jshint', 'webpack', 'karma:without_coverage']);
grunt.registerTask('with_coverage', ['jshint', 'webpack', 'karma:with_coverage']);
grunt.registerTask('default', ['eslint', 'webpack', 'karma:without_coverage']);
grunt.registerTask('with_coverage', ['eslint', 'webpack', 'karma:with_coverage']);
};
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -4,6 +4,8 @@ Javascript library for Jose JWE and JWS
[![license](http://img.shields.io/badge/license-apache_2.0-red.svg?style=flat)](https://raw.githubusercontent.com/square/js-jose/master/LICENSE)
[![build](https://travis-ci.org/square/js-jose.svg?branch=master)](https://travis-ci.org/square/js-jose)
[![coverage](https://img.shields.io/coveralls/square/js-jose.svg?branch=master&style=flat)](https://coveralls.io/r/square/js-jose)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)


Overview
--------
Expand Down

0 comments on commit 8f065ce

Please sign in to comment.