Skip to content

Commit 91a87b8

Browse files
committed
eslint and prettier
1 parent 70aa23c commit 91a87b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2190
-1844
lines changed

.eslintrc

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,67 +13,23 @@
1313
"Float32Array": true,
1414
"Uint8Array": true
1515
},
16+
"extends": ["eslint:recommended", "prettier"],
17+
"plugins": ["prettier"],
1618
"rules": {
17-
"block-scoped-var": 0,
18-
"camelcase": 0,
19-
"comma-style": [
20-
2,
21-
"last"
22-
],
23-
"dot-notation": [
19+
"prettier/prettier": ["error"],
20+
"no-cond-assign": [2, "except-parens"],
21+
"eqeqeq": ["error", "smart"],
22+
"no-use-before-define": [
2423
2,
2524
{
26-
"allowKeywords": true
25+
"functions": false
2726
}
2827
],
29-
"eqeqeq": [
30-
2,
31-
"allow-null"
32-
],
33-
"eol-last": ["error", "always"],
34-
"guard-for-in": 2,
35-
"indent": ["error", 2, { "SwitchCase": 1 }],
36-
"max-len": [1, 120, 2, { "ignoreComments": true }],
37-
"new-cap": 2,
28+
"new-cap": 0,
3829
"no-caller": 2,
39-
"no-cond-assign": [
40-
2,
41-
"except-parens"
42-
],
43-
"no-debugger": 2,
44-
"no-empty": 2,
45-
"no-eval": 2,
46-
"no-extend-native": 2,
47-
"no-extra-parens": 2,
48-
"no-extra-semi": 2,
49-
"no-irregular-whitespace": 2,
50-
"no-trailing-spaces": 2,
51-
"no-iterator": 2,
52-
"no-loop-func": 0,
53-
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }],
54-
"no-multi-str": 2,
55-
"no-new": 2,
56-
"no-plusplus": 0,
57-
"no-proto": 2,
58-
"no-script-url": 2,
59-
"no-sequences": 2,
60-
"no-shadow": 2,
61-
"no-undef": 2,
62-
"no-unused-vars": 2,
63-
"no-with": 2,
64-
"quotes": [
65-
2,
66-
"single"
67-
],
68-
"semi": [
69-
2
70-
],
71-
"space-before-blocks": "error",
72-
"strict": 2,
73-
"valid-typeof": 2,
74-
"wrap-iife": [
75-
2,
76-
"inside"
77-
]
30+
"no-undef": 0,
31+
"no-unused-vars": ["error", { "args": "none" }],
32+
"no-empty": ["error", { "allowEmptyCatch": true }],
33+
"no-console": "off"
7834
}
7935
}

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Gruntfile.js
2+
test/test.js
3+
webpack.config.js
4+
lib/

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

Gruntfile.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ module.exports = function(grunt) {
2323
// Configure style consistency
2424
eslint: {
2525
source: {
26-
options: {configFile: './.eslintrc'},
26+
options: {
27+
configFile: './.eslintrc',
28+
fix: true
29+
},
2730
src: ['src/**/*.js', 'test/tests/**/*.js']
2831
}
2932
},
@@ -56,7 +59,7 @@ module.exports = function(grunt) {
5659
}
5760
});
5861

59-
62+
6063
grunt.loadNpmTasks('grunt-webpack');
6164
grunt.loadNpmTasks('grunt-eslint');
6265
grunt.loadNpmTasks('grunt-contrib-connect');
@@ -65,7 +68,7 @@ module.exports = function(grunt) {
6568

6669
grunt.registerTask('lint', ['eslint:source']);
6770
grunt.registerTask('default', ['webpack:prod', 'decomment']);
68-
grunt.registerTask('dev', ['connect','webpack:dev', 'decomment']);
71+
grunt.registerTask('dev', ['eslint','connect','webpack:dev', 'decomment']);
6972
grunt.registerTask('serve', 'connect:server:keepalive');
7073
grunt.registerTask('run-tests', ['serve', 'open']);
7174
};

package-lock.json

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"amdclean": "~2.0",
1414
"babel-loader": "^8.0.6",
1515
"babel-plugin-preval": "^3.0.1",
16+
"eslint-config-prettier": "^6.11.0",
17+
"eslint-plugin-prettier": "^3.1.3",
1618
"grunt": "~0.4.5",
1719
"grunt-cli": "^0.1.13",
1820
"grunt-contrib-connect": "^1.0.2",
@@ -21,6 +23,7 @@
2123
"grunt-mocha": "^1.0.4",
2224
"grunt-open": "^0.2.3",
2325
"grunt-webpack": "^3.1.3",
26+
"prettier": "2.0.5",
2427
"raw-loader": "^3.0.0",
2528
"uglify-loader": "^3.0.0",
2629
"uglifyjs-webpack-plugin": "^2.1.3",
@@ -30,7 +33,8 @@
3033
"dependencies": {
3134
"audioworklet-polyfill": "^1.1.2",
3235
"startaudiocontext": "^1.2.1",
33-
"tone": "0.10.0"
36+
"tone": "0.10.0",
37+
"tslint-config-prettier": "^1.18.0"
3438
},
3539
"scripts": {
3640
"build": "grunt",

src/amplitude.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ define(function (require) {
4747
*
4848
* </code></div>
4949
*/
50-
p5.Amplitude = function(smoothing) {
51-
50+
p5.Amplitude = function (smoothing) {
5251
// Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default
5352
this.bufferSize = safeBufferSize(2048);
5453

5554
// set audio context
5655
this.audiocontext = p5sound.audiocontext;
57-
this._workletNode = new AudioWorkletNode(this.audiocontext, processorNames.amplitudeProcessor, {
58-
outputChannelCount: [1],
56+
this._workletNode = new AudioWorkletNode(
57+
this.audiocontext,
58+
processorNames.amplitudeProcessor,
59+
{
60+
outputChannelCount: [1],
5961

60-
parameterData: { smoothing: smoothing || 0 },
61-
processorOptions: {
62-
normalize: false,
63-
smoothing: smoothing || 0,
64-
numInputChannels: 2,
65-
bufferSize: this.bufferSize
62+
parameterData: { smoothing: smoothing || 0 },
63+
processorOptions: {
64+
normalize: false,
65+
smoothing: smoothing || 0,
66+
numInputChannels: 2,
67+
bufferSize: this.bufferSize,
68+
},
6669
}
67-
});
70+
);
6871

69-
this._workletNode.port.onmessage = function(event) {
72+
this._workletNode.port.onmessage = function (event) {
7073
if (event.data.name === 'amplitude') {
7174
this.volume = event.data.volume;
7275
this.volNorm = event.data.volNorm;
@@ -146,8 +149,7 @@ define(function (require) {
146149
* }
147150
* </code></div>
148151
*/
149-
p5.Amplitude.prototype.setInput = function(source, smoothing) {
150-
152+
p5.Amplitude.prototype.setInput = function (source, smoothing) {
151153
p5sound.meter.disconnect();
152154

153155
if (smoothing) {
@@ -156,7 +158,9 @@ define(function (require) {
156158

157159
// connect to the master out of p5s instance if no snd is provided
158160
if (source == null) {
159-
console.log('Amplitude input source is not ready! Connecting to master output instead');
161+
console.log(
162+
'Amplitude input source is not ready! Connecting to master output instead'
163+
);
160164
p5sound.meter.connect(this._workletNode);
161165
}
162166

@@ -177,7 +181,7 @@ define(function (require) {
177181
}
178182
};
179183

180-
p5.Amplitude.prototype.connect = function(unit) {
184+
p5.Amplitude.prototype.connect = function (unit) {
181185
if (unit) {
182186
if (unit.hasOwnProperty('input')) {
183187
this.output.connect(unit.input);
@@ -189,7 +193,7 @@ define(function (require) {
189193
}
190194
};
191195

192-
p5.Amplitude.prototype.disconnect = function() {
196+
p5.Amplitude.prototype.disconnect = function () {
193197
if (this.output) {
194198
this.output.disconnect();
195199
}
@@ -234,18 +238,16 @@ define(function (require) {
234238
* }
235239
* </code></div>
236240
*/
237-
p5.Amplitude.prototype.getLevel = function(channel) {
241+
p5.Amplitude.prototype.getLevel = function (channel) {
238242
if (typeof channel !== 'undefined') {
239243
if (this.normalize) {
240244
return this.stereoVolNorm[channel];
241245
} else {
242246
return this.stereoVol[channel];
243247
}
244-
}
245-
else if (this.normalize) {
248+
} else if (this.normalize) {
246249
return this.volNorm;
247-
}
248-
else {
250+
} else {
249251
return this.volume;
250252
}
251253
};
@@ -264,14 +266,16 @@ define(function (require) {
264266
* @for p5.Amplitude
265267
* @param {boolean} [boolean] set normalize to true (1) or false (0)
266268
*/
267-
p5.Amplitude.prototype.toggleNormalize = function(bool) {
269+
p5.Amplitude.prototype.toggleNormalize = function (bool) {
268270
if (typeof bool === 'boolean') {
269271
this.normalize = bool;
270-
}
271-
else {
272+
} else {
272273
this.normalize = !this.normalize;
273274
}
274-
this._workletNode.port.postMessage({ name: 'toggleNormalize', normalize: this.normalize });
275+
this._workletNode.port.postMessage({
276+
name: 'toggleNormalize',
277+
normalize: this.normalize,
278+
});
275279
};
276280

277281
/**
@@ -282,15 +286,15 @@ define(function (require) {
282286
* @for p5.Amplitude
283287
* @param {Number} set smoothing from 0.0 <= 1
284288
*/
285-
p5.Amplitude.prototype.smooth = function(s) {
289+
p5.Amplitude.prototype.smooth = function (s) {
286290
if (s >= 0 && s < 1) {
287291
this._workletNode.port.postMessage({ name: 'smoothing', smoothing: s });
288292
} else {
289293
console.log('Error: smoothing must be between 0 and 1');
290294
}
291295
};
292296

293-
p5.Amplitude.prototype.dispose = function() {
297+
p5.Amplitude.prototype.dispose = function () {
294298
// remove reference from soundArray
295299
var index = p5sound.soundArray.indexOf(this);
296300
p5sound.soundArray.splice(index, 1);
@@ -307,5 +311,4 @@ define(function (require) {
307311
this._workletNode.disconnect();
308312
delete this._workletNode;
309313
};
310-
311314
});

src/app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
define(function (require) {
4-
54
require('audioworklet-polyfill');
65
require('shims');
76
require('audiocontext');
@@ -40,5 +39,4 @@ define(function (require) {
4039
require('polysynth');
4140

4241
return p5SOUND;
43-
4442
});

0 commit comments

Comments
 (0)