Skip to content

Commit

Permalink
FAQ page for JQ syntax (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
evg4b committed Nov 2, 2024
1 parent e5c8566 commit 7d47d5a
Show file tree
Hide file tree
Showing 49 changed files with 8,479 additions and 954 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI (nodejs and golang)

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore artifacts:
dist
coverage
.yarn
.idea
media_data/data/**/*.json
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"experimentalTernaries": false,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto"
}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@
# Browser compatibility:

| | Browser name | Support |
|------------------------------------------------------------------------------------------------------------------|----------------|---------|
| <img src="https://www.google.com/chrome/static/images/chrome-logo.svg" height="30px"> | Google Chrome | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/2/28/Chromium_Logo.svg" height="30px"> | Chromium | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/4/49/Opera_2015_icon.svg" height="30px"> | Opera | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/5/51/Brave_icon_lionface.png" height="30px"> | Brave | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/8/80/Yandex_Browser_logo.svg" height="30px"> | Yandex Browser | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Arc_%28browser%29_logo.svg" height="30px"> | Arc Browser | |
| <img src="https://upload.wikimedia.org/wikipedia/commons/7/7e/Microsoft_Edge_logo_%282019%29.png" height="30px"> | Microsoft Edge | |
| ---------------------------------------------------------------------------------------------------------------- | -------------- | ------- |
| <img src="https://www.google.com/chrome/static/images/chrome-logo.svg" height="30px"> | Google Chrome ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/2/28/Chromium_Logo.svg" height="30px"> | Chromium ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/4/49/Opera_2015_icon.svg" height="30px"> | Opera ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/5/51/Brave_icon_lionface.png" height="30px"> | Brave ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/8/80/Yandex_Browser_logo.svg" height="30px"> | Yandex Browser ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Arc_%28browser%29_logo.svg" height="30px"> | Arc Browser ||
| <img src="https://upload.wikimedia.org/wikipedia/commons/7/7e/Microsoft_Edge_logo_%282019%29.png" height="30px"> | Microsoft Edge ||

If you can't find your browser in the list, please try to install the extension and if it doesn't work,
[create a request for browser support](https://github.com/evg4b/modern-json-formatter/issues/new?title=Browser%20support%20request&body=%23%20Browser%20Support%20Request%0A%0ABrowser%20Details%3A%0A-%20Name%3A%20____%20%5Be.g.%2C%20Firefox%5D%0A-%20Version%20*(optional)*%3A%20____%20%5Be.g.%2C%20114.0%5D%0A-%20Platform%20*(optional)*%3A%20____%20%5Be.g.%2C%20Windows%5D%0A%0AAdditional%20Info%3A%0A-%20Link%20to%20the%20browser%20website%3A%20____).
[create a request for browser support](<https://github.com/evg4b/modern-json-formatter/issues/new?title=Browser%20support%20request&body=%23%20Browser%20Support%20Request%0A%0ABrowser%20Details%3A%0A-%20Name%3A%20____%20%5Be.g.%2C%20Firefox%5D%0A-%20Version%20*(optional)*%3A%20____%20%5Be.g.%2C%20114.0%5D%0A-%20Platform%20*(optional)*%3A%20____%20%5Be.g.%2C%20Windows%5D%0A%0AAdditional%20Info%3A%0A-%20Link%20to%20the%20browser%20website%3A%20____>).

# Support the project:

Expand Down
17 changes: 10 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default tseslint.config(
'dist/',
'jest.config.js',
'media_data/',
'tsup.config.js',
'packages/wasm_exec.js',
'eslint.config.mjs',
'coverage/'
'coverage/',
'tsup.config.mjs'
],
},
eslint.configs.recommended,
Expand All @@ -22,10 +22,13 @@ export default tseslint.config(
{
rules: {
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/restrict-template-expressions': ['error', {
allowNumber: true,
}]
}
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNumber: true,
},
],
},
},
{
languageOptions: {
Expand All @@ -34,5 +37,5 @@ export default tseslint.config(
tsconfigRootDir: import.meta.dirname,
},
},
},
}
);
9 changes: 3 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ module.exports = {
collectCoverage: true,
showSeed: true,
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [
'/node_modules/',
'/.yarn/',
],
coveragePathIgnorePatterns: ['/node_modules/', '/.yarn/'],
coverageProvider: 'v8',
coverageReporters: ['lcov', 'text'],
collectCoverageFrom: [
Expand All @@ -34,9 +31,9 @@ module.exports = {
'^.+\\.[tj]sx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.spec.json'
tsconfig: 'tsconfig.spec.json',
},
],
'^.+\\.scss$': 'jest-transform-stub',
},
}
};
1 change: 0 additions & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ import { TextDecoder, TextEncoder } from 'text-encoding';
global.TextDecoder = TextDecoder;
global.TextEncoder = TextEncoder;
import './packages/wasm_exec.js';

12 changes: 6 additions & 6 deletions media_data/run.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer from 'puppeteer';
import { resolve } from "node:path";
import { resolve } from 'node:path';

const pathToExtension = resolve(process.cwd(), '..', 'dist');

Expand All @@ -10,16 +10,16 @@ const pathToExtension = resolve(process.cwd(), '..', 'dist');
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
`--window-size=1280,720`
`--window-size=1280,720`,
],
defaultViewport: {
width: 1280,
height: 720
}
height: 720,
},
});
const page = await browser.newPage();
const website_url = 'http://modern-json-formatter.example/numbers.json';

// Open URL in current page
await page.goto(website_url, { waitUntil: 'networkidle0' })
// Open URL in current page
await page.goto(website_url, { waitUntil: 'networkidle0' });
})();
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test": "jest"
},
"devDependencies": {
"@chialab/esbuild-plugin-html": "^0.18.2",
"@eslint/js": "^9.13.0",
"@jest/globals": "^29.7.0",
"@types/chrome": "^0.0.279",
Expand All @@ -40,6 +41,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-transform-stub": "^2.0.0",
"prettier": "3.3.3",
"sass-embedded": "^1.80.4",
"text-encoding": "^0.7.0",
"ts-jest": "^29.2.5",
Expand Down
6 changes: 4 additions & 2 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WASMs for modern-json-formatter
# WASMs for modern-json-formatter

Custom json tokenizer written in GO and compiled to WASM.

Expand All @@ -11,7 +11,9 @@ The output of the tokenizer is a schema that represents the json structure and v
Null node:

```js
{ type: "null" }
{
type: 'null';
}
```

Number node:
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/import-wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const importWasm = async (go: Go, wasmFile: string) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const webAssemblyInstance = await loadWasm(chrome.runtime.getURL(wasmFile), go.importObject);

void go.run(webAssemblyInstance.instance)
.then(() => console.log(`Wasm module ${ wasmFile } loaded successfully`))
void go
.run(webAssemblyInstance.instance)
.then(() => console.log(`Wasm module ${wasmFile} loaded successfully`))
.catch((error: unknown) => console.error(error))
.finally(() => console.log('Wasm module loaded'));
};

5 changes: 3 additions & 2 deletions packages/shared/wasm_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type WebAssemblyInstantiatedSource = WebAssembly.WebAssemblyInstantiatedSource;
export const loadWasm = (url: string, imports: Imports): Promise<WebAssemblyInstantiatedSource> => {
return 'instantiateStreaming' in WebAssembly
? WebAssembly.instantiateStreaming(fetch(url), imports)
: fetch(url).then(resp => resp.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, imports));
: fetch(url)
.then(resp => resp.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, imports));
};
7 changes: 1 addition & 6 deletions packages/tokenizer/tokenizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jest.mock('../shared/wasm_helpers.ts', () => ({
},
}));


describe('jq', () => {
beforeAll(chromeMockBefore);

Expand All @@ -18,10 +17,6 @@ describe('jq', () => {
test('should return a TokenizerResponse', async () => {
const data = await tokenize('{ "data": 123 }');

expect(data).toEqual(
tObject(
tProperty('data', tNumber(`123`)),
),
);
expect(data).toEqual(tObject(tProperty('data', tNumber(`123`))));
});
});
Loading

0 comments on commit 7d47d5a

Please sign in to comment.