From f9ead120d8a6c1bf10f6790df56d0d7a01d33d6d Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Sun, 6 Feb 2022 15:21:08 +0900 Subject: [PATCH 01/44] refactoring prettier setup (#35) --- .github/workflows/codeql-analysis.yml | 58 ++-- .prettierignore | 11 + apps/www/.eslintrc.json | 6 +- apps/www/.rubocop.yml | 6 +- .../javascripts/serviceworker-companion.js | 8 +- .../www/app/assets/stylesheets/gate_popup.css | 2 +- .../assets/stylesheets/quantum_simulator.css | 6 +- apps/www/app/assets/stylesheets/tippy.css | 22 +- apps/www/app/assets/stylesheets/variables.css | 166 ----------- .../components/gate_popup_component.html.erb | 12 +- apps/www/app/views/circuits/index.html.erb | 262 ++++++++++++++++-- apps/www/app/views/circuits/show.html.erb | 10 +- apps/www/config/locales/en.yml | 2 +- apps/www/package.json | 2 - apps/www/postcss.config.js | 20 +- apps/www/public/404.html | 116 ++++---- apps/www/public/422.html | 116 ++++---- apps/www/public/500.html | 114 ++++---- docs/application.css | 36 +-- docs/application.js.map | 4 +- docs/package.json | 5 +- examples/elements-example/postcss.config.js | 14 +- examples/elements-example/src/application.css | 2 +- package.json | 6 +- packages/common/.eslintrc.json | 2 +- packages/elements/.eslintrc.json | 2 +- packages/elements/css/angle_slider.css | 2 +- packages/elements/css/bloch_display.css | 12 +- packages/elements/css/circuit_dropzone.css | 4 +- packages/elements/css/circuit_step.css | 2 +- packages/elements/css/measurement_gate.css | 4 +- packages/elements/css/qni.css | 2 +- packages/elements/css/run_circuit_button.css | 4 +- packages/elements/css/tippy.css | 18 +- packages/elements/css/write_gate.css | 6 +- .../elements/src/circuit-dropzone-element.ts | 2 +- packages/elements/src/mixin/iconable.ts | 2 +- .../src/run-circuit-button-element.ts | 4 +- packages/simulator/.eslintrc.json | 2 +- yarn.lock | 4 +- 40 files changed, 562 insertions(+), 516 deletions(-) delete mode 100644 apps/www/app/assets/stylesheets/variables.css diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3df9167d4..d5a347b9a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,14 +9,14 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ main ] + branches: [main] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: [main] schedule: - cron: '16 9 * * 6' @@ -32,39 +32,39 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript', 'ruby' ] + language: ['javascript', 'ruby'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language - #- run: | - # make bootstrap - # make release + #- run: | + # make bootstrap + # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.prettierignore b/.prettierignore index 0dee7f056..bd29b78ca 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,14 @@ +*.rb +apps/www/app/assets/builds/ +apps/www/db/ +apps/www/docs/ +dist +docs/_includes/navigation.html +docs/_site/ docs/application.css docs/application.js docs/serviceworker.js +examples/elements-example/public/ +packages/common/docs/ +packages/elements/docs/ +packages/simulator/docs/ diff --git a/apps/www/.eslintrc.json b/apps/www/.eslintrc.json index 581c2e98f..ba4a53b40 100644 --- a/apps/www/.eslintrc.json +++ b/apps/www/.eslintrc.json @@ -1,9 +1,5 @@ { - "extends": [ - "plugin:github/recommended", - "plugin:github/browser", - "plugin:github/typescript" - ], + "extends": ["plugin:github/recommended", "plugin:github/browser", "plugin:github/typescript", "prettier"], "rules": { "i18n-text/no-en": "off", "import/named": "off" diff --git a/apps/www/.rubocop.yml b/apps/www/.rubocop.yml index 44b7b133b..2fcd15722 100644 --- a/apps/www/.rubocop.yml +++ b/apps/www/.rubocop.yml @@ -20,9 +20,9 @@ AllCops: TargetRailsVersion: 6.0 NewCops: enable Exclude: - - "bin/*" - - "db/**/*" - - "tmp/**/*" + - 'bin/*' + - 'db/**/*' + - 'tmp/**/*' # Lint Lint/MissingSuper: diff --git a/apps/www/app/assets/javascripts/serviceworker-companion.js b/apps/www/app/assets/javascripts/serviceworker-companion.js index 58e323c2f..1d310a4d0 100644 --- a/apps/www/app/assets/javascripts/serviceworker-companion.js +++ b/apps/www/app/assets/javascripts/serviceworker-companion.js @@ -1,7 +1,5 @@ if (navigator.serviceWorker) { - navigator.serviceWorker - .register("/serviceworker.js", { scope: "./" }) - .catch(function (error) { - console.log("[Companion]", "Service worker registration failed: " + error) - }) + navigator.serviceWorker.register('/serviceworker.js', {scope: './'}).catch(function (error) { + console.log('[Companion]', 'Service worker registration failed: ' + error) + }) } diff --git a/apps/www/app/assets/stylesheets/gate_popup.css b/apps/www/app/assets/stylesheets/gate_popup.css index 8075ebf44..2bff44cdf 100644 --- a/apps/www/app/assets/stylesheets/gate_popup.css +++ b/apps/www/app/assets/stylesheets/gate_popup.css @@ -1,6 +1,6 @@ .gate-popup { &__input-wrapper { - @apply border-2 border-swan; + @apply border-swan border-2; @apply px-3 py-2; @apply relative; @apply rounded-md; diff --git a/apps/www/app/assets/stylesheets/quantum_simulator.css b/apps/www/app/assets/stylesheets/quantum_simulator.css index 4e5a3e949..7d403aaf2 100644 --- a/apps/www/app/assets/stylesheets/quantum_simulator.css +++ b/apps/www/app/assets/stylesheets/quantum_simulator.css @@ -1,7 +1,7 @@ quantum-simulator { - .circle-notation[data-nqubit="8"], - .circle-notation[data-nqubit="9"], - .circle-notation[data-nqubit="10"] { + .circle-notation[data-nqubit='8'], + .circle-notation[data-nqubit='9'], + .circle-notation[data-nqubit='10'] { @apply md:overflow-y-scroll; @apply md:h-40; } diff --git a/apps/www/app/assets/stylesheets/tippy.css b/apps/www/app/assets/stylesheets/tippy.css index c4cb745f8..356b5b9d9 100644 --- a/apps/www/app/assets/stylesheets/tippy.css +++ b/apps/www/app/assets/stylesheets/tippy.css @@ -1,37 +1,37 @@ -@import "tippy.js/dist/border.css"; -@import "tippy.js/dist/svg-arrow.css"; -@import "tippy.js/dist/tippy.css"; +@import 'tippy.js/dist/border.css'; +@import 'tippy.js/dist/svg-arrow.css'; +@import 'tippy.js/dist/tippy.css'; -.tippy-box[data-theme~="qni"] { +.tippy-box[data-theme~='qni'] { @apply bg-snow; - @apply border-2 border-solid border-eel; + @apply border-eel border-2 border-solid; @apply text-wolf; @apply text-xs; @apply md:text-sm; /* The border */ .tippy-svg-arrow > svg:first-child { - fill: theme("colors.eel"); + fill: theme('colors.eel'); } /* The fill */ .tippy-svg-arrow > svg:last-child { - fill: theme("colors.snow"); + fill: theme('colors.snow'); } - &[data-placement^="top"] > .tippy-svg-arrow svg:first-child { + &[data-placement^='top'] > .tippy-svg-arrow svg:first-child { top: 18px; } - &[data-placement^="bottom"] > .tippy-svg-arrow svg:first-child { + &[data-placement^='bottom'] > .tippy-svg-arrow svg:first-child { bottom: 18px; } - &[data-placement^="left"] > .tippy-svg-arrow svg:first-child { + &[data-placement^='left'] > .tippy-svg-arrow svg:first-child { left: 13px; } - &[data-placement^="right"] > .tippy-svg-arrow svg:first-child { + &[data-placement^='right'] > .tippy-svg-arrow svg:first-child { right: 13px; } diff --git a/apps/www/app/assets/stylesheets/variables.css b/apps/www/app/assets/stylesheets/variables.css deleted file mode 100644 index 529d29b9e..000000000 --- a/apps/www/app/assets/stylesheets/variables.css +++ /dev/null @@ -1,166 +0,0 @@ -$nqubits: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; - -/* Instructions */ -$instruction-size-extralarge: 12; -$instruction-size-large: 10; -$instruction-size-base: 8; -$instruction-size-small: 6; -$instruction-size-extrasmall: 4; - -$instruction-size-screen-md: 8; - -$instruction-size: ( - 1: $instruction-size-extralarge, - 2: $instruction-size-extralarge, - 3: $instruction-size-large, - 4: $instruction-size-base, - 5: $instruction-size-small, - 6: $instruction-size-small, - 7: $instruction-size-extrasmall, - 8: $instruction-size-extrasmall, - 9: $instruction-size-extrasmall, - 10: $instruction-size-extrasmall, -); - -$instruction-label-font-size-large: 2xl; -$instruction-label-font-size-base: base; -$instruction-label-font-size-small: base; -$instruction-label-font-size-extrasmall: xs; - -$instruction-label-font-size: ( - 1: $instruction-label-font-size-large, - 2: $instruction-label-font-size-large, - 3: $instruction-label-font-size-large, - 4: $instruction-label-font-size-base, - 5: $instruction-label-font-size-small, - 6: $instruction-label-font-size-small, - 7: $instruction-label-font-size-extrasmall, - 8: $instruction-label-font-size-extrasmall, - 9: $instruction-label-font-size-extrasmall, - 10: $instruction-label-font-size-extrasmall, -); - -/* Gate label */ -$gate-label-font-size-extralarge: base; -$gate-label-font-size-large: base; -$gate-label-font-size-base: base; -$gate-label-font-size-small: sm; -$gate-label-font-size-extrasmall: xs; -$gate-label-font-size-extraextrasmall: xxs; - -$gate-label-font-size: ( - 1: $gate-label-font-size-extralarge, - 2: $gate-label-font-size-large, - 3: $gate-label-font-size-large, - 4: $gate-label-font-size-base, - 5: $gate-label-font-size-small, - 6: $gate-label-font-size-small, - 7: $gate-label-font-size-extrasmall, - 8: $gate-label-font-size-extraextrasmall, - 9: $gate-label-font-size-extraextrasmall, - 10: $gate-label-font-size-extraextrasmall, -); - -/* Wire */ -$wire-width: 2; - -$connection-width-base: 4; -$connection-width: ( - 1: 4, - 2: 4, - 3: 4, - 4: 4, - 5: 4, - 6: 4, - 7: 4, - 8: 2, - 9: 2, - 10: 2, -); - -/* Circuit Breakpoint */ -$circuit-breakpoint-width-px: 4; - -/* write & measure gate */ -$gate-ket-label-font-size: ( - 1: $instruction-label-font-size-large, - 2: $instruction-label-font-size-large, - 3: $instruction-label-font-size-large, - 4: $instruction-label-font-size-base, - 5: $instruction-label-font-size-small, - 6: $instruction-label-font-size-small, - 7: $instruction-label-font-size-extrasmall, - 8: $instruction-label-font-size-extrasmall, - 9: $instruction-label-font-size-extrasmall, - 10: $instruction-label-font-size-extrasmall, -); - -/* Circle notation */ -$circle-notation-height: 40; -$circle-notation-height-mobile: 32; -$circle-notation-margin-top: 12; - -/* Qubit Circle */ -$qubit-circle-size-2xl: 16; -$qubit-circle-size-xl: 12; -$qubit-circle-size-large: 8; -$qubit-circle-size-base: 6; -$qubit-circle-size-sm: 4; - -$qubit-circle-size-px: ( - 1: $qubit-circle-size-2xl * 4, - 2: $qubit-circle-size-2xl * 4, - 3: $qubit-circle-size-2xl * 4, - 4: $qubit-circle-size-xl * 4, - 5: $qubit-circle-size-large * 4, - 6: $qubit-circle-size-base * 4 + 1, - 7: $qubit-circle-size-sm * 4 + 1, - 8: $qubit-circle-size-sm * 4 + 1, - 9: $qubit-circle-size-sm * 4 + 1, - 10: $qubit-circle-size-sm * 4 + 1, -); - -$qubit-circle-size-px-mobile: ( - 1: $qubit-circle-size-2xl * 4, - 2: $qubit-circle-size-2xl * 4, - 3: $qubit-circle-size-xl * 4, - 4: $qubit-circle-size-large * 4, - 5: $qubit-circle-size-base * 4 - 1, - 6: $qubit-circle-size-sm * 4 - 1, - 7: $qubit-circle-size-sm * 4 - 1, - 8: $qubit-circle-size-sm * 4 - 1, - 9: $qubit-circle-size-sm * 4 - 1, - 10: $qubit-circle-size-sm * 4 - 1, -); - -$stroke-width-px-bold: 2; -$stroke-width-px-base: 1; - -$qubit-circle-border-width-px: ( - 1: $stroke-width-px-bold, - 2: $stroke-width-px-bold, - 3: $stroke-width-px-bold, - 4: $stroke-width-px-bold, - 5: $stroke-width-px-bold, - 6: $stroke-width-px-base, - 7: $stroke-width-px-base, - 8: $stroke-width-px-base, - 9: $stroke-width-px-base, - 10: $stroke-width-px-base, -); - -$qubit-circle-border-width-px-mobile: ( - 1: $stroke-width-px-bold, - 2: $stroke-width-px-bold, - 3: $stroke-width-px-bold, - 4: $stroke-width-px-bold, - 5: $stroke-width-px-base, - 6: $stroke-width-px-base, - 7: $stroke-width-px-base, - 8: $stroke-width-px-base, - 9: $stroke-width-px-base, - 10: $stroke-width-px-base, -); - -/* Run button */ -$run-button-z: 40; diff --git a/apps/www/app/components/gate_popup_component.html.erb b/apps/www/app/components/gate_popup_component.html.erb index 071c6bd05..da912c5dd 100644 --- a/apps/www/app/components/gate_popup_component.html.erb +++ b/apps/www/app/components/gate_popup_component.html.erb @@ -1,10 +1,14 @@