Merge pull request #305 from tidalcycles/estlint-prettier-check
add lint + prettier check before test
This commit is contained in:
commit
03450c6085
19 changed files with 89 additions and 88 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -14,6 +14,8 @@ jobs:
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- run: npm install
|
- run: npm install
|
||||||
|
- run: npm run format-check
|
||||||
|
- run: npm run lint
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
**/out
|
**/out
|
||||||
**/dist
|
**/dist
|
||||||
packages/mini/krill-parser.js
|
packages/mini/krill-parser.js
|
||||||
|
packages/xen/tunejs.js
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,3 @@
|
||||||
"htmlWhitespaceSensitivity": "css",
|
"htmlWhitespaceSensitivity": "css",
|
||||||
"endOfLine": "lf"
|
"endOfLine": "lf"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"description": "Port of tidalcycles to javascript",
|
"description": "Port of tidalcycles to javascript",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "cd tutorial && npm run jsdoc-json",
|
"pretest": "cd tutorial && npm run jsdoc-json",
|
||||||
"test": "npm run lint && vitest run --version",
|
"test": "vitest run --version",
|
||||||
"test-ui": "vitest --ui",
|
"test-ui": "vitest --ui",
|
||||||
"test-coverage": "vitest --coverage",
|
"test-coverage": "vitest --coverage",
|
||||||
"bootstrap": "lerna bootstrap",
|
"bootstrap": "lerna bootstrap",
|
||||||
|
|
@ -18,8 +18,10 @@
|
||||||
"deploy": "NODE_DEBUG=gh-pages gh-pages -d out",
|
"deploy": "NODE_DEBUG=gh-pages gh-pages -d out",
|
||||||
"jsdoc": "jsdoc packages/ -c jsdoc.config.json",
|
"jsdoc": "jsdoc packages/ -c jsdoc.config.json",
|
||||||
"jsdoc-json": "jsdoc packages/ --template ./node_modules/jsdoc-json --destination doc.json -c jsdoc.config.json",
|
"jsdoc-json": "jsdoc packages/ --template ./node_modules/jsdoc-json --destination doc.json -c jsdoc.config.json",
|
||||||
"lint": "npx eslint . --ext mjs,js --quiet",
|
"lint": "eslint . --ext mjs,js --quiet",
|
||||||
"codeformat": "prettier --write ."
|
"codeformat": "prettier --write .",
|
||||||
|
"format-check": "prettier --check .",
|
||||||
|
"check": "npm run format-check && npm run lint && npm run test"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ evalScope(
|
||||||
import('@strudel.cycles/tonal'),
|
import('@strudel.cycles/tonal'),
|
||||||
);
|
);
|
||||||
|
|
||||||
setStringParser(mini)
|
setStringParser(mini);
|
||||||
|
|
||||||
const { evaluate } = repl({
|
const { evaluate } = repl({
|
||||||
defaultOutput: webaudioOutput,
|
defaultOutput: webaudioOutput,
|
||||||
|
|
|
||||||
|
|
@ -80,16 +80,16 @@ export class Hap {
|
||||||
}
|
}
|
||||||
|
|
||||||
show(compact = false) {
|
show(compact = false) {
|
||||||
const value = typeof this.value === 'object'
|
const value =
|
||||||
|
typeof this.value === 'object'
|
||||||
? compact
|
? compact
|
||||||
? JSON.stringify(this.value).slice(1, -1).replaceAll('"', '').replaceAll(',', ' ')
|
? JSON.stringify(this.value).slice(1, -1).replaceAll('"', '').replaceAll(',', ' ')
|
||||||
: JSON.stringify(this.value)
|
: JSON.stringify(this.value)
|
||||||
: this.value
|
: this.value;
|
||||||
var spans = '';
|
var spans = '';
|
||||||
if (this.whole == undefined) {
|
if (this.whole == undefined) {
|
||||||
spans = '~' + this.part.show;
|
spans = '~' + this.part.show;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var is_whole = this.whole.begin.equals(this.part.begin) && this.whole.end.equals(this.part.end);
|
var is_whole = this.whole.begin.equals(this.part.begin) && this.whole.end.equals(this.part.end);
|
||||||
if (!this.whole.begin.equals(this.part.begin)) {
|
if (!this.whole.begin.equals(this.part.begin)) {
|
||||||
spans = this.whole.begin.show() + ' ⇜ ';
|
spans = this.whole.begin.show() + ' ⇜ ';
|
||||||
|
|
@ -102,12 +102,10 @@ export class Hap {
|
||||||
spans += ')';
|
spans += ')';
|
||||||
}
|
}
|
||||||
if (!this.whole.end.equals(this.part.end)) {
|
if (!this.whole.end.equals(this.part.end)) {
|
||||||
spans += ' ⇝ ' + this.whole.end.show()
|
spans += ' ⇝ ' + this.whole.end.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return '[ ' + spans + ' | ' + value + ' ]';
|
||||||
'[ ' + spans + ' | ' + value + ' ]'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showWhole(compact = false) {
|
showWhole(compact = false) {
|
||||||
|
|
|
||||||
|
|
@ -558,17 +558,16 @@ export class Pattern {
|
||||||
if (a.part.begin.eq(b.part.end)) {
|
if (a.part.begin.eq(b.part.end)) {
|
||||||
if (a_value === JSON.stringify(b.value)) {
|
if (a_value === JSON.stringify(b.value)) {
|
||||||
// eat the matching hap into 'a'
|
// eat the matching hap into 'a'
|
||||||
a = new Hap(a.whole, new TimeSpan(b.part.begin, a.part.end), a.value)
|
a = new Hap(a.whole, new TimeSpan(b.part.begin, a.part.end), a.value);
|
||||||
haps.splice(j, 1);
|
haps.splice(j, 1);
|
||||||
// restart the search
|
// restart the search
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (b.part.begin.eq(a.part.end)) {
|
||||||
else if (b.part.begin.eq(a.part.end)) {
|
|
||||||
if (a_value == JSON.stringify(b.value)) {
|
if (a_value == JSON.stringify(b.value)) {
|
||||||
// eat the matching hap into 'a'
|
// eat the matching hap into 'a'
|
||||||
a = new Hap(a.whole, new TimeSpan(a.part.begin, b.part.end), a.value)
|
a = new Hap(a.whole, new TimeSpan(a.part.begin, b.part.end), a.value);
|
||||||
haps.splice(j, 1);
|
haps.splice(j, 1);
|
||||||
// restart the search
|
// restart the search
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
||||||
|
|
@ -917,20 +917,18 @@ describe('Pattern', () => {
|
||||||
});
|
});
|
||||||
describe('defragmentHaps', () => {
|
describe('defragmentHaps', () => {
|
||||||
it('Can merge two touching haps with same whole and value', () => {
|
it('Can merge two touching haps with same whole and value', () => {
|
||||||
expect(stack(pure('a').mask(1,0), pure('a').mask(0,1)).defragmentHaps().firstCycle().length)
|
expect(stack(pure('a').mask(1, 0), pure('a').mask(0, 1)).defragmentHaps().firstCycle().length).toStrictEqual(1);
|
||||||
.toStrictEqual(1);
|
|
||||||
});
|
});
|
||||||
it('Doesnt merge two overlapping haps', () => {
|
it('Doesnt merge two overlapping haps', () => {
|
||||||
expect(stack(pure('a').mask(1,1,0), pure('a').mask(0,1)).defragmentHaps().firstCycle().length)
|
expect(stack(pure('a').mask(1, 1, 0), pure('a').mask(0, 1)).defragmentHaps().firstCycle().length).toStrictEqual(
|
||||||
.toStrictEqual(2);
|
2,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it('Doesnt merge two touching haps with different values', () => {
|
it('Doesnt merge two touching haps with different values', () => {
|
||||||
expect(stack(pure('a').mask(1,0), pure('b').mask(0,1)).defragmentHaps().firstCycle().length)
|
expect(stack(pure('a').mask(1, 0), pure('b').mask(0, 1)).defragmentHaps().firstCycle().length).toStrictEqual(2);
|
||||||
.toStrictEqual(2);
|
|
||||||
});
|
});
|
||||||
it('Doesnt merge two touching haps with different wholes', () => {
|
it('Doesnt merge two touching haps with different wholes', () => {
|
||||||
expect(stack(sequence('a', silence), pure('a').mask(0,1)).defragmentHaps().firstCycle().length)
|
expect(stack(sequence('a', silence), pure('a').mask(0, 1)).defragmentHaps().firstCycle().length).toStrictEqual(2);
|
||||||
.toStrictEqual(2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export class TimeSpan {
|
||||||
|
|
||||||
// Support zero-width timespans
|
// Support zero-width timespans
|
||||||
if (begin.equals(end)) {
|
if (begin.equals(end)) {
|
||||||
return([new TimeSpan(begin, end)]);
|
return [new TimeSpan(begin, end)];
|
||||||
}
|
}
|
||||||
|
|
||||||
while (end.gt(begin)) {
|
while (end.gt(begin)) {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ const config = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
|
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
|
||||||
|
|
||||||
osc.open(); // start a WebSocket server on port 8080
|
osc.open(); // start a WebSocket server on port 8080
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()]
|
plugins: [react()],
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ module.exports = {
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
import React from 'react'
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom';
|
||||||
import App from './App'
|
import App from './App';
|
||||||
|
|
||||||
ReactDOM.render(<React.StrictMode><App /></React.StrictMode>,document.getElementById('root'))
|
ReactDOM.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>,
|
||||||
|
document.getElementById('root'),
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,16 @@ export async function getWriter(br = 38400) {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const writer = port.writable.getWriter();
|
const writer = port.writable.getWriter();
|
||||||
writeMessage = function (message, chk) {
|
writeMessage = function (message, chk) {
|
||||||
const encoded = encoder.encode(message)
|
const encoded = encoder.encode(message);
|
||||||
if (!chk) {
|
if (!chk) {
|
||||||
writer.write(encoded);
|
writer.write(encoded);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const bytes = new Uint8Array(4);
|
const bytes = new Uint8Array(4);
|
||||||
bytes[0] = 124; // | symbol
|
bytes[0] = 124; // | symbol
|
||||||
bytes[1] = (chk >> 8) & 0xFF;
|
bytes[1] = (chk >> 8) & 0xff;
|
||||||
bytes[2] = chk & 0xFF;
|
bytes[2] = chk & 0xff;
|
||||||
bytes[3] = 59; // semicolon
|
bytes[3] = 59; // semicolon
|
||||||
const withchk = new Uint8Array(encoded.length+4)
|
const withchk = new Uint8Array(encoded.length + 4);
|
||||||
withchk.set(encoded);
|
withchk.set(encoded);
|
||||||
withchk.set(bytes, encoded.length);
|
withchk.set(bytes, encoded.length);
|
||||||
writer.write(withchk);
|
writer.write(withchk);
|
||||||
|
|
@ -48,12 +47,12 @@ const latency = 0.1;
|
||||||
|
|
||||||
// crc16 (CCITT-FALSE) https://gist.github.com/tijnkooijmans/10981093
|
// crc16 (CCITT-FALSE) https://gist.github.com/tijnkooijmans/10981093
|
||||||
function crc16(data) {
|
function crc16(data) {
|
||||||
const length = data.length
|
const length = data.length;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var crc = 0xFFFF;
|
var crc = 0xffff;
|
||||||
for (var i = 0; i < length; ++i) {
|
for (var i = 0; i < length; ++i) {
|
||||||
crc ^= data.charCodeAt(i) << 8;
|
crc ^= data.charCodeAt(i) << 8;
|
||||||
for (var j = 0; j < 8; ++j) {
|
for (var j = 0; j < 8; ++j) {
|
||||||
|
|
@ -96,7 +95,7 @@ Pattern.prototype.serial = function (br=38400,sendcrc=false,singlecharids=false)
|
||||||
}
|
}
|
||||||
message += ')';
|
message += ')';
|
||||||
if (sendcrc) {
|
if (sendcrc) {
|
||||||
chk = crc16(message)
|
chk = crc16(message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const [key, val] of Object.entries(hap.value)) {
|
for (const [key, val] of Object.entries(hap.value)) {
|
||||||
|
|
@ -108,7 +107,9 @@ Pattern.prototype.serial = function (br=38400,sendcrc=false,singlecharids=false)
|
||||||
}
|
}
|
||||||
const offset = (time - currentTime + latency) * 1000;
|
const offset = (time - currentTime + latency) * 1000;
|
||||||
|
|
||||||
window.setTimeout(function () {writeMessage(message, chk)}, offset);
|
window.setTimeout(function () {
|
||||||
|
writeMessage(message, chk);
|
||||||
|
}, offset);
|
||||||
};
|
};
|
||||||
return hap.setContext({ ...hap.context, onTrigger, dominantTrigger: true });
|
return hap.setContext({ ...hap.context, onTrigger, dominantTrigger: true });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ module.exports = {
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
||||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||||
sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
||||||
monospace;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ module.exports = {
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue