-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #842 from Stuk/eslint
Replace jshint with eslint
- Loading branch information
Showing
69 changed files
with
7,069 additions
and
1,573 deletions.
There are no files selected for viewing
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,43 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"ignorePatterns": ["vendor/*.js", "dist/*.js", "test/jquery-1.8.3.min.js"], | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"curly": "error", | ||
"eqeqeq": "error", | ||
"no-new": "error", | ||
"no-caller": "error", | ||
"guard-for-in": "error", | ||
"no-extend-native": "error", | ||
"strict": [ | ||
"error", | ||
"global" | ||
], | ||
} | ||
}; |
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,67 +1,46 @@ | ||
/*jshint node: true */ | ||
"use strict"; | ||
|
||
module.exports = function(grunt) { | ||
var version = require("./package.json").version; | ||
var version = require("./package.json").version; | ||
|
||
grunt.initConfig({ | ||
jshint: { | ||
// see https://github.com/gruntjs/grunt-contrib-jshint/issues/198 | ||
// we can't override the options using the jshintrc path | ||
options: grunt.file.readJSON('.jshintrc'), | ||
production: ['./lib/**/*.js'], | ||
test: ['./test/helpers/**/*.js', './test/asserts/**/*.js'], | ||
documentation: { | ||
options: { | ||
// we include js files with jekyll, jshint can't see all | ||
// variables and we can't declare all of them | ||
undef: false, | ||
// 'implied' still give false positives in our case | ||
strict: false | ||
grunt.initConfig({ | ||
browserify: { | ||
all: { | ||
files: { | ||
"dist/jszip.js": ["lib/index.js"] | ||
}, | ||
options: { | ||
browserifyOptions: { | ||
standalone: "JSZip", | ||
transform: ["package-json-versionify"], | ||
insertGlobalVars: { | ||
process: undefined, | ||
Buffer: undefined, | ||
__filename: undefined, | ||
__dirname: undefined | ||
}, | ||
builtins: false | ||
}, | ||
banner: grunt.file.read("lib/license_header.js").replace(/__VERSION__/, version) | ||
} | ||
} | ||
}, | ||
files: { | ||
src: ['./documentation/**/*.js'] | ||
} | ||
} | ||
}, | ||
browserify: { | ||
all: { | ||
files: { | ||
'dist/jszip.js': ['lib/index.js'] | ||
}, | ||
options: { | ||
browserifyOptions: { | ||
standalone: 'JSZip', | ||
transform: ['package-json-versionify'], | ||
insertGlobalVars: { | ||
process: undefined, | ||
Buffer: undefined, | ||
__filename: undefined, | ||
__dirname: undefined | ||
uglify: { | ||
options: { | ||
mangle: true, | ||
preserveComments: false, | ||
banner: grunt.file.read("lib/license_header.js").replace(/__VERSION__/, version) | ||
}, | ||
builtins: false | ||
}, | ||
banner: grunt.file.read('lib/license_header.js').replace(/__VERSION__/, version) | ||
all: { | ||
src: "dist/jszip.js", | ||
dest: "dist/jszip.min.js" | ||
} | ||
} | ||
} | ||
}, | ||
uglify: { | ||
options: { | ||
mangle: true, | ||
preserveComments: false, | ||
banner: grunt.file.read('lib/license_header.js').replace(/__VERSION__/, version) | ||
}, | ||
all: { | ||
src: 'dist/jszip.js', | ||
dest: 'dist/jszip.min.js' | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-browserify'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks("grunt-browserify"); | ||
grunt.loadNpmTasks("grunt-contrib-uglify"); | ||
|
||
grunt.registerTask("build", ["browserify", "uglify"]); | ||
grunt.registerTask("default", ["jshint", "build"]); | ||
grunt.registerTask("build", ["browserify", "uglify"]); | ||
grunt.registerTask("default", ["build"]); | ||
}; |
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,12 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
globals: { | ||
$: false, | ||
jQuery: false, | ||
JSZip: false, | ||
JSZipUtils: false, | ||
// From FileSaver.js | ||
saveAs: false, | ||
}, | ||
}; |
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,3 +1,5 @@ | ||
"use strict"; | ||
|
||
var zip = new JSZip(); | ||
zip.file("Hello.txt", "Hello world\n"); | ||
|
||
|
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,3 +1,5 @@ | ||
"use strict"; | ||
|
||
var zip = new JSZip(); | ||
zip.file("Hello.txt", "Hello world\n"); | ||
|
||
|
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
48 changes: 25 additions & 23 deletions
48
documentation/examples/get-binary-files-ajax.inc/fetch_api.js
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,23 +1,25 @@ | ||
fetch('{{site.baseurl}}/test/ref/text.zip') // 1) fetch the url | ||
.then(function (response) { // 2) filter on 200 OK | ||
if (response.status === 200 || response.status === 0) { | ||
return Promise.resolve(response.blob()); | ||
} else { | ||
return Promise.reject(new Error(response.statusText)); | ||
} | ||
}) | ||
.then(JSZip.loadAsync) // 3) chain with the zip promise | ||
.then(function (zip) { | ||
return zip.file("Hello.txt").async("string"); // 4) chain with the text content promise | ||
}) | ||
.then(function success(text) { // 5) display the result | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-success", | ||
text: "loaded, content = " + text | ||
})); | ||
}, function error(e) { | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-danger", | ||
text: e | ||
})); | ||
}); | ||
"use strict"; | ||
|
||
fetch("{{site.baseurl}}/test/ref/text.zip") // 1) fetch the url | ||
.then(function (response) { // 2) filter on 200 OK | ||
if (response.status === 200 || response.status === 0) { | ||
return Promise.resolve(response.blob()); | ||
} else { | ||
return Promise.reject(new Error(response.statusText)); | ||
} | ||
}) | ||
.then(JSZip.loadAsync) // 3) chain with the zip promise | ||
.then(function (zip) { | ||
return zip.file("Hello.txt").async("string"); // 4) chain with the text content promise | ||
}) | ||
.then(function success(text) { // 5) display the result | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-success", | ||
text: "loaded, content = " + text | ||
})); | ||
}, function error(e) { | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-danger", | ||
text: e | ||
})); | ||
}); |
Oops, something went wrong.