Applied eslint from main .eslintrc to examples (#418)

* Changed eslintrc to be JSON file (Most projects use JSON version)
  * Added .eslintignore to ingore node_modules from subdirectories such as examples
  * Ran eslint --fix examples to fix all examples
  * Added npm script for running eslint against examples
  * Added npm script for running eslint against generated *out* code
  * Hooked npm scripts into travis ci to prevent examples from becoming inconsistent with future PR's
This commit is contained in:
Frank Hassanabad 2018-07-08 00:02:10 -06:00 committed by Alex Crichton
parent 9482a1fa9a
commit 6561fba947
35 changed files with 260 additions and 252 deletions

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
node_modules

34
.eslintrc Normal file
View File

@ -0,0 +1,34 @@
{
"env": {
"es6": true,
"browser": true,
"commonjs": true,
"node": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": ["error", 4],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": 0,
"no-undef": "warn"
},
"globals": {
"BigInt64Array": true,
"BigUint64Array": true
}
}

View File

@ -1,34 +0,0 @@
module.exports = {
env: {
es6: true,
browser: true,
commonjs: true,
node: true
},
extends: 'eslint:recommended',
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
rules: {
indent: ['error', 4],
'linebreak-style': [
'error',
'unix'
],
quotes: [
'error',
'single'
],
semi: [
'error',
'always'
],
'no-console': 0,
'no-undef': 'warn'
},
globals: {
BigInt64Array: true,
BigUint64Array: true
}
};

View File

@ -40,7 +40,9 @@ matrix:
script: script:
- cargo test - cargo test
# Check JS output from all tests against eslint # Check JS output from all tests against eslint
- ./node_modules/.bin/eslint ./target/generated-tests/*/out*js - npm run run-lint-generated-tests
# Check Examples against eslint
- npm run run-lint-examples
addons: addons:
firefox: latest firefox: latest

View File

@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./add"); const rust = import('./add');
rust.then(m => alert('1 + 2 = ' + m.add(1, 2))); rust.then(m => alert('1 + 2 = ' + m.add(1, 2)));

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,85 +1,86 @@
export let chars = [ export let chars = [
"!","#","$","%","&","'","(",")","*","+",",", '!','#','$','%','&','\'','(',')','*','+',',',
"-",".","/","0","1","2","3","4","5","6","7", '-','.','/','0','1','2','3','4','5','6','7',
"8","9",":",";","<","=",">","?","@","A","B", '8','9',':',';','<','=','>','?','@','A','B',
"C","D","E","F","G","H","I","J","K","L","M", 'C','D','E','F','G','H','I','J','K','L','M',
"N","O","P","Q","R","S","T","U","V","W","X", 'N','O','P','Q','R','S','T','U','V','W','X',
"Y","Z","[","]","^","_","`","a","b","c", 'Y','Z','[',']','^','_','`','a','b','c',
"d","e","f","g","h","i","j","k","l","m","n", 'd','e','f','g','h','i','j','k','l','m','n',
"o","p","q","r","s","t","u","v","w","x","y", 'o','p','q','r','s','t','u','v','w','x','y',
"z","{","|","}","~"," ","¡","¢","£","¤","¥", 'z','{','|','}','~',' ','¡','¢','£','¤','¥',
"¦","§","¨","©","ª","«","¬","®","¯","°", '¦','§','¨','©','ª','«','¬','®','¯','°',
"±","²","³","´","µ","¶","·","¸","¹","º","»", '±','²','³','´','µ','¶','·','¸','¹','º','»',
"¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ", '¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ',
"Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ", 'Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ',
"Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü", 'Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü',
"Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç", 'Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç',
"è","é","ê","ë","ì","í","î","ï","ð","ñ","ò", 'è','é','ê','ë','ì','í','î','ï','ð','ñ','ò',
"ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý", 'ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý',
"þ","ÿ","Ā","ā","Ă","ă","Ą","ą","Ć","ć","Ĉ", 'þ','ÿ','Ā','ā','Ă','ă','Ą','ą','Ć','ć','Ĉ',
"ĉ","Ċ","ċ","Č","č","Ď","ď","Đ","đ","Ē","ē", 'ĉ','Ċ','ċ','Č','č','Ď','ď','Đ','đ','Ē','ē',
"Ĕ","ĕ","Ė","ė","Ę","ę","Ě","ě","Ĝ","ĝ","Ğ", 'Ĕ','ĕ','Ė','ė','Ę','ę','Ě','ě','Ĝ','ĝ','Ğ',
"ğ","Ġ","ġ","Ģ","ģ","Ĥ","ĥ","Ħ","ħ","Ĩ","ĩ", 'ğ','Ġ','ġ','Ģ','ģ','Ĥ','ĥ','Ħ','ħ','Ĩ','ĩ',
"Ī","ī","Ĭ","ĭ","Į","į","İ","ı","IJ","ij","Ĵ", 'Ī','ī','Ĭ','ĭ','Į','į','İ','ı','IJ','ij','Ĵ',
"ĵ","Ķ","ķ","ĸ","Ĺ","ĺ","Ļ","ļ","Ľ","ľ","Ŀ", 'ĵ','Ķ','ķ','ĸ','Ĺ','ĺ','Ļ','ļ','Ľ','ľ','Ŀ',
"ŀ","Ł","ł","Ń","ń","Ņ","ņ","Ň","ň","ʼn","Ŋ", 'ŀ','Ł','ł','Ń','ń','Ņ','ņ','Ň','ň','ʼn','Ŋ',
"ŋ","Ō","ō","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','Ο','Π','Ρ','Σ','Τ','Υ','Φ',
"Χ","Ψ","Ω","Ϊ","Ϋ","ά","έ","ή","ί","ΰ","α", 'Χ','Ψ','Ω','Ϊ','Ϋ','ά','έ','ή','ί','ΰ','α',
"β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ", 'β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ',
"ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ", 'ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ',
"ψ","ω","ϊ","ϋ","ό","ύ","ώ","Ϗ","ϐ","ϑ","ϒ", 'ψ','ω','ϊ','ϋ','ό','ύ','ώ','Ϗ','ϐ','ϑ','ϒ',
"ϓ","ϔ","ϕ","ϖ","ϗ","Ϙ","ϙ","Ϛ","ϛ","Ϝ","ϝ", 'ϓ','ϔ','ϕ','ϖ','ϗ','Ϙ','ϙ','Ϛ','ϛ','Ϝ','ϝ',
"Ϟ","ϟ","Ϡ","ϡ","Ϣ","ϣ","Ϥ","ϥ","Ϧ","ϧ","Ϩ", 'Ϟ','ϟ','Ϡ','ϡ','Ϣ','ϣ','Ϥ','ϥ','Ϧ','ϧ','Ϩ',
"ϩ","Ϫ","ϫ","Ϭ","ϭ","Ϯ","ϯ","ϰ","ϱ","ϲ","ϳ", 'ϩ','Ϫ','ϫ','Ϭ','ϭ','Ϯ','ϯ','ϰ','ϱ','ϲ','ϳ',
"Օ","Ֆ","🕧","🕨","🕩","🕪","🕫","🕬","🕭","🕮", 'Օ','Ֆ','🕧','🕨','🕩','🕪','🕫','🕬','🕭','🕮',
"🕯","🕰","🕱","🕲","🕳","🕴","🕵","🕶","🕷","🕸", '🕯','🕰','🕱','🕲','🕳','🕴','🕵','🕶','🕷','🕸',
"🕹","🕺","🕻","🕼","🕽","🕾","🕿","🖀","🖁","🖂", '🕹','🕺','🕻','🕼','🕽','🕾','🕿','🖀','🖁','🖂',
"🖃","🖄","🖅","🖆","🖇","🖈","🖉","🖊","🖋", '🖃','🖄','🖅','🖆','🖇','🖈','🖉','🖊','🖋',
"🖌","🖍","🖎","🖏","🖐","🖑","🖒","🖓","🖔","🖕", '🖌','🖍','🖎','🖏','🖐','🖑','🖒','🖓','🖔','🖕',
"🖖","🖗","🖘","🖙","🖚","🖛","🖜","🖝","🖞","🖟", '🖖','🖗','🖘','🖙','🖚','🖛','🖜','🖝','🖞','🖟',
"🖠","🖡","🖢","🖣","🖤","🖥","🖦","🖧","🖨","🖩", '🖠','🖡','🖢','🖣','🖤','🖥','🖦','🖧','🖨','🖩',
"🖪","🖫","🖬","🖭","🖮","🖯","🖰","🖱","🖲","🖳", '🖪','🖫','🖬','🖭','🖮','🖯','🖰','🖱','🖲','🖳',
"🖴","🖵","🖶","🖷","🖸","🖹","🖺","🖻","🖼","🖽", '🖴','🖵','🖶','🖷','🖸','🖹','🖺','🖻','🖼','🖽',
"🖾","🖿","🗀","🗁","🗂","🗃","🗄","🗅","🗆","🗇", '🖾','🖿','🗀','🗁','🗂','🗃','🗄','🗅','🗆','🗇',
"🗈","🗉","🗊","🗋","🗌","🗍","🗎","🗏","🗐","🗑","🗒", '🗈','🗉','🗊','🗋','🗌','🗍','🗎','🗏','🗐','🗑','🗒',
"🗓","🗔","🗕","🗖","🗗","🗘","🗙","🗚","🗛","🗜", '🗓','🗔','🗕','🗖','🗗','🗘','🗙','🗚','🗛','🗜',
"🗝","🗞","🗟","🗠","🗡","🗢","🗣","🗤","🗥","🗦", '🗝','🗞','🗟','🗠','🗡','🗢','🗣','🗤','🗥','🗦',
"🗧","🗨","🗩","🗪","🗫","🗬","🗭","🗮","🗯","🗰", '🗧','🗨','🗩','🗪','🗫','🗬','🗭','🗮','🗯','🗰',
"🗱","🗲","🗳","🗴","🗵","🗶","🗷","🗸","🗹","🗺", '🗱','🗲','🗳','🗴','🗵','🗶','🗷','🗸','🗹','🗺',
"🗻","🗼","🗽","🗾","🗿","😀"]; '🗻','🗼','🗽','🗾','🗿','😀'];

View File

@ -1,5 +1,6 @@
import {chars} from './chars.js' /* eslint-disable no-unused-vars */
let imp = import('./char.js') import {chars} from './chars.js';
let imp = import('./char.js');
let mod; let mod;
let counters = []; let counters = [];
@ -8,7 +9,7 @@ imp.then(wasm => {
addCounter(); addCounter();
let b = document.getElementById('add-counter'); let b = document.getElementById('add-counter');
if (!b) throw new Error('Unable to find #add-counter'); if (!b) throw new Error('Unable to find #add-counter');
b.addEventListener('click', ev => addCounter()) b.addEventListener('click', ev => addCounter());
}); });
function addCounter() { function addCounter() {
@ -21,7 +22,7 @@ function update() {
let container = document.getElementById('container'); let container = document.getElementById('container');
if (!container) throw new Error('Unable to find #container in dom'); if (!container) throw new Error('Unable to find #container in dom');
while (container.hasChildNodes()) { while (container.hasChildNodes()) {
if (container.lastChild.id == "add-counter") break; if (container.lastChild.id == 'add-counter') break;
container.removeChild(container.lastChild); container.removeChild(container.lastChild);
} }
for (var i = 0; i < counters.length; i++) { for (var i = 0; i < counters.length; i++) {
@ -29,7 +30,7 @@ function update() {
container.appendChild(newCounter(counter.key(), counter.count(), ev => { container.appendChild(newCounter(counter.key(), counter.count(), ev => {
counter.increment(); counter.increment();
update(); update();
})) }));
} }
} }

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./closures"); const rust = import('./closures');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
const mod = import('./comments'); const mod = import('./comments');
let wasm; let wasm;
mod.then(m => { mod.then(m => {
@ -48,7 +49,7 @@ function storeComments() {
name: c.name(), name: c.name(),
comment: c.comment(), comment: c.comment(),
count: c.count, count: c.count,
} };
}); });
localStorage.setItem('comments', JSON.stringify(json)); localStorage.setItem('comments', JSON.stringify(json));
} }
@ -118,10 +119,10 @@ function renderComment(comment) {
bottom.appendChild(title); bottom.appendChild(title);
let text = document.createElement('span'); let text = document.createElement('span');
text.setAttribute('class', 'comment-text'); text.setAttribute('class', 'comment-text');
text.appendChild(document.createTextNode(comment.comment())) text.appendChild(document.createTextNode(comment.comment()));
bottom.appendChild(text); bottom.appendChild(text);
div.appendChild(top); div.appendChild(top);
div.appendChild(bottom) div.appendChild(bottom);
return div; return div;
} }

View File

@ -1,11 +1,11 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development", mode: 'development',
devtool: 'source-map', devtool: 'source-map',
}; };

View File

@ -1,5 +1,5 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./console_log"); const rust = import('./console_log');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./dom"); const rust = import('./dom');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,6 +1,6 @@
// Note that a dynamic `import` statement here is required due to // Note that a dynamic `import` statement here is required due to
// webpack/webpack#6615, but in theory `import { greet } from './hello_world';` // webpack/webpack#6615, but in theory `import { greet } from './hello_world';`
// will work here one day as well! // will work here one day as well!
const rust = import("./hello_world"); const rust = import('./hello_world');
rust.then(m => m.greet("World!")); rust.then(m => m.greet('World!'));

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,5 +1,5 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./import_js"); const rust = import('./import_js');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,6 +1,6 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./math"); const rust = import('./math');
rust.then(m => { rust.then(m => {
m.run(); m.run();

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./performance"); const rust = import('./performance');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -2,7 +2,7 @@
[View this example online](https://webassembly.studio/?f=t61j18noqz) [View this example online](https://webassembly.studio/?f=t61j18noqz)
This directory is an smattering of examples using the `#[wasm_bindgen]` macro. This directory is a smattering of examples using the `#[wasm_bindgen]` macro.
Here we see passing strings back and for, exporting classes from Rust to JS, Here we see passing strings back and for, exporting classes from Rust to JS,
importing classes from JS to Rust, etc. importing classes from JS to Rust, etc.

View File

@ -1,4 +1,4 @@
import { Foo, Bar, concat } from "./smorgasboard"; import { Foo, Bar, concat } from './smorgasboard';
function assertEq(a, b) { function assertEq(a, b) {
if (a !== b) if (a !== b)
@ -18,7 +18,7 @@ foo.free();
// Pass objects to one another // Pass objects to one another
let foo1 = new Foo(); let foo1 = new Foo();
let bar = Bar.from_str("22", { opaque: 'object' }); let bar = Bar.from_str('22', { opaque: 'object' });
foo1.add_other(bar); foo1.add_other(bar);
// We also don't have to `free` the `bar` variable as this function is // We also don't have to `free` the `bar` variable as this function is
@ -29,4 +29,4 @@ foo1.consume_other(bar);
assertEq(foo1.add(2), 22 + 34 + 2); assertEq(foo1.add(2), 22 + 34 + 2);
foo1.free(); foo1.free();
alert('all passed!') alert('all passed!');

View File

@ -1 +1 @@
import("./app"); import('./app');

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world` // For more comments about what's going on here, check out the `hello_world`
// example // example
const rust = import("./wasm_in_wasm"); const rust = import('./wasm_in_wasm');
rust.then(m => m.run()); rust.then(m => m.run());

View File

@ -1,10 +1,10 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
entry: "./index.js", entry: './index.js',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "index.js", filename: 'index.js',
}, },
mode: "development" mode: 'development'
}; };

View File

@ -3,10 +3,13 @@
"scripts": { "scripts": {
"run-webpack": "webpack", "run-webpack": "webpack",
"run-webpack-dev-server": "webpack-dev-server", "run-webpack-dev-server": "webpack-dev-server",
"run-geckodriver": "geckodriver" "run-geckodriver": "geckodriver",
"run-lint-examples": "eslint ./examples",
"run-lint-generated-tests": "eslint ./target/generated-tests/*/out*js"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^10.5.2", "@types/node": "^10.5.2",
"babel-eslint": "^8.2.5",
"eslint": "^5.0.1", "eslint": "^5.0.1",
"geckodriver": "^1.11.0", "geckodriver": "^1.11.0",
"selenium-webdriver": "^4.0.0-alpha.1", "selenium-webdriver": "^4.0.0-alpha.1",
@ -14,7 +17,6 @@
"typescript": "^2.7.2", "typescript": "^2.7.2",
"webpack": "^4.15.1", "webpack": "^4.15.1",
"webpack-cli": "^3.0.8", "webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4", "webpack-dev-server": "^3.1.4"
"babel-eslint": "^8.2.5"
} }
} }