From 046799c56a7144c3c0cf278c4adf57614969be86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20K=C3=B6ves?= <3187531+vkoves@users.noreply.github.com> Date: Tue, 7 Jan 2025 21:52:00 -0600 Subject: [PATCH] Switch Prettier to single quotes --- .eslintrc.js | 136 +- .github/workflows/eslint.yml | 4 +- .github/workflows/pytest.yml | 8 +- .prettierrc | 4 +- README.md | 2 +- docker-compose.yml | 4 +- gridsome.config.js | 26 +- gridsome.server.js | 52 +- src/common-functions.vue | 28 +- src/components/BuildingImage.vue | 10 +- src/components/BuildingsTable.vue | 12 +- src/components/DataDisclaimer.vue | 8 +- src/components/DataSourceFootnote.vue | 4 +- src/components/EmailBuildingModal.vue | 22 +- src/components/EmissionsBreakdownGraph.vue | 4 +- .../HistoricalBuildingDataTable.vue | 14 +- src/components/NewTabIcon.vue | 2 +- src/components/OverallRankEmoji.vue | 8 +- src/components/OwnerLogo.vue | 8 +- src/components/RankText.vue | 10 +- src/components/ReportingTile.vue | 18 +- src/components/StatTile.vue | 84 +- src/components/graphs/BarGraph.vue | 46 +- src/components/graphs/PieChart.vue | 48 +- src/components/graphs/SparkLine.vue | 126 +- src/components/layout/AppFooter.vue | 4 +- src/components/layout/AppHeader.vue | 8 +- src/components/layout/Popup.vue | 6 +- src/constants/building-images.constant.vue | 210 +-- .../buildings-custom-info.constant.vue | 1588 ++++++++--------- src/layouts/Default.vue | 6 +- src/main.js | 30 +- src/pages/About.vue | 8 +- src/pages/BiggestBuildings.vue | 12 +- src/pages/BiggestGasFreeBuildings.vue | 12 +- src/pages/Blog.vue | 8 +- src/pages/CleanestBuildings.vue | 14 +- src/pages/Index.vue | 14 +- src/pages/LargeOwners.vue | 12 +- src/pages/Map.vue | 86 +- src/pages/ReleaseNotes.vue | 6 +- src/pages/RetrofitChicagoParticipants.vue | 16 +- src/pages/Search.vue | 30 +- src/pages/TakeActionTips.vue | 6 +- src/pages/TopElectricityUsers.vue | 12 +- src/pages/TopEmitters.vue | 12 +- src/pages/TopGasUsers.vue | 12 +- src/pages/blog/MillionsInMissedFines.vue | 10 +- src/scss/global.scss | 8 +- src/templates/BuildingDetails.vue | 84 +- src/templates/BuildingIDRedirect.vue | 4 +- src/templates/BuildingOwner.vue | 18 +- src/vue-shims.d.ts | 4 +- 53 files changed, 1465 insertions(+), 1463 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8064101c..d55a120a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,20 +5,20 @@ module.exports = { es2021: true, }, extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:vue/recommended", + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:vue/recommended', ], parserOptions: { - parser: "@typescript-eslint/parser", - project: "./tsconfig.json", - extraFileExtensions: [".vue"], + parser: '@typescript-eslint/parser', + project: './tsconfig.json', + extraFileExtensions: ['.vue'], }, - plugins: ["vue"], + plugins: ['vue'], rules: { - "max-len": [ - "error", + 'max-len': [ + 'error', { code: 100, // Fixes errors in HTML files with long links @@ -27,71 +27,71 @@ module.exports = { ], // Disable stylistic rules that interfere with Prettier - "vue/html-closing-bracket-newline": "off", - "vue/html-self-closing": "off", - "vue/max-attributes-per-line": "off", - "vue/singleline-html-element-content-newline": "off", - "vue/html-indent": "off", + 'vue/html-closing-bracket-newline': 'off', + 'vue/html-self-closing': 'off', + 'vue/max-attributes-per-line': 'off', + 'vue/singleline-html-element-content-newline': 'off', + 'vue/html-indent': 'off', - "vue/multi-word-component-names": ["off"], + 'vue/multi-word-component-names': ['off'], // This rule is for Vue3, and Gridsome uses Vue2 - "vue/no-deprecated-filter": ["off"], + 'vue/no-deprecated-filter': ['off'], // Don't make multiline, it adds spaces - "vue/multiline-html-element-content-newline": [ - "error", + 'vue/multiline-html-element-content-newline': [ + 'error', { ignores: [ - "g-link", + 'g-link', // Original inline elements from: https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/utils/inline-non-void-elements.json - "a", - "abbr", - "audio", - "b", - "bdi", - "bdo", - "canvas", - "cite", - "code", - "data", - "del", - "dfn", - "em", - "i", - "iframe", - "ins", - "kbd", - "label", - "map", - "mark", - "noscript", - "object", - "output", - "picture", - "q", - "ruby", - "s", - "samp", - "small", - "span", - "strong", - "sub", - "sup", - "svg", - "time", - "u", - "var", - "video", + 'a', + 'abbr', + 'audio', + 'b', + 'bdi', + 'bdo', + 'canvas', + 'cite', + 'code', + 'data', + 'del', + 'dfn', + 'em', + 'i', + 'iframe', + 'ins', + 'kbd', + 'label', + 'map', + 'mark', + 'noscript', + 'object', + 'output', + 'picture', + 'q', + 'ruby', + 's', + 'samp', + 'small', + 'span', + 'strong', + 'sub', + 'sup', + 'svg', + 'time', + 'u', + 'var', + 'video', ], }, ], - "@typescript-eslint/indent": ["error", 2], - semi: ["error", "always"], - "arrow-parens": ["error", "always"], - "comma-dangle": ["error", "always-multiline"], + '@typescript-eslint/indent': ['error', 2], + semi: ['error', 'always'], + 'arrow-parens': ['error', 'always'], + 'comma-dangle': ['error', 'always-multiline'], - "@typescript-eslint/explicit-function-return-type": [ - "error", + '@typescript-eslint/explicit-function-return-type': [ + 'error', { allowExpressions: true, allowHigherOrderFunctions: true, @@ -101,11 +101,11 @@ module.exports = { }, overrides: [ { - files: ["*.vue", "declarations/*.ts"], + files: ['*.vue', 'declarations/*.ts'], rules: { - indent: "off", - "@typescript-eslint/indent": "off", - "@typescript-eslint/no-var-requires": 0, + indent: 'off', + '@typescript-eslint/indent': 'off', + '@typescript-eslint/no-var-requires': 0, }, }, ], diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index ca811495..dfbb594e 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -7,10 +7,10 @@ name: ESLint & Prettier on: push: - branches: ["main"] + branches: ['main'] pull_request: # The branches below must be a subset of the branches above - branches: ["main"] + branches: ['main'] jobs: eslint: diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b9a9953e..bb09991b 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -4,21 +4,21 @@ name: Pytest Data Tests on: push: - branches: ["main"] + branches: ['main'] pull_request: # The branches below must be a subset of the branches above - branches: ["main"] + branches: ['main'] jobs: pytest: - name: "Pytest" + name: 'Pytest' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: '3.9' - name: Install dependencies run: | cd src/data diff --git a/.prettierrc b/.prettierrc index 0967ef42..544138be 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1 +1,3 @@ -{} +{ + "singleQuote": true +} diff --git a/README.md b/README.md index b1b6dbd0..e1ef228e 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Example: ```ts const BuildingOwnerIds = [ - "iit", + 'iit', // ... ]; ``` diff --git a/docker-compose.yml b/docker-compose.yml index 4d2d1474..02fc07d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: electrify-chicago: @@ -7,7 +7,7 @@ services: context: . dockerfile: Dockerfile ports: - - "8080:8080" + - '8080:8080' entrypoint: /app/docker-entrypoint.sh volumes: - .:/app diff --git a/gridsome.config.js b/gridsome.config.js index b07fe0a7..e10b5524 100644 --- a/gridsome.config.js +++ b/gridsome.config.js @@ -4,7 +4,7 @@ // Changes here require a server restart. // To restart press CTRL + C in terminal and run `gridsome develop` -const path = require("path"); +const path = require('path'); /** * A function that loads in all our global SCSS files @@ -13,18 +13,18 @@ const path = require("path"); */ function addStyleResource(rule) { rule - .use("style-resource") - .loader("style-resources-loader") + .use('style-resource') + .loader('style-resources-loader') .options({ - patterns: [path.resolve(__dirname, "./src/scss/*.scss")], + patterns: [path.resolve(__dirname, './src/scss/*.scss')], }); } module.exports = { - siteName: "Electrify Chicago", + siteName: 'Electrify Chicago', plugins: [ { - use: "gridsome-plugin-typescript", + use: 'gridsome-plugin-typescript', }, ], @@ -32,14 +32,14 @@ module.exports = { // Register building details path Building: [ { - path: "/building/:slugSource", - component: "./src/templates/BuildingDetails.vue", + path: '/building/:slugSource', + component: './src/templates/BuildingDetails.vue', }, { // A path that redirects from a building ID to the canonical slug URL - name: "building-id-redirect", - path: "/building-id/:ID", - component: "./src/templates/BuildingIDRedirect.vue", + name: 'building-id-redirect', + path: '/building-id/:ID', + component: './src/templates/BuildingIDRedirect.vue', }, ], }, @@ -47,11 +47,11 @@ module.exports = { // Ensure /scss folder is globally available chainWebpack(config) { // Load variables for all vue-files - const types = ["vue-modules", "vue", "normal-modules", "normal"]; + const types = ['vue-modules', 'vue', 'normal-modules', 'normal']; // or if you use scss types.forEach((type) => { - addStyleResource(config.module.rule("scss").oneOf(type)); + addStyleResource(config.module.rule('scss').oneOf(type)); }); }, }; diff --git a/gridsome.server.js b/gridsome.server.js index 0b274d7e..cb50e812 100644 --- a/gridsome.server.js +++ b/gridsome.server.js @@ -9,31 +9,31 @@ * From fetching CSV data: * https://gridsome.org/docs/fetching-data/#csv */ -const { readFileSync } = require("fs"); -const parse = require("csv-parse/sync").parse; +const { readFileSync } = require('fs'); +const parse = require('csv-parse/sync').parse; -const DataDirectory = "./src/data/dist/"; +const DataDirectory = './src/data/dist/'; -const BuildingEmissionsDataFile = "building-benchmarks.csv"; -const HistoricBenchmarkingDataFile = "benchmarking-all-years.csv"; +const BuildingEmissionsDataFile = 'building-benchmarks.csv'; +const HistoricBenchmarkingDataFile = 'benchmarking-all-years.csv'; // This is an array equivalent of Object.keys(BuildingOwners) but this file can't use Typescript and // import that file const BuildingOwnerIds = [ - "depaul", - "uchicago", - "uic", - "iit", - "northwestern", - "loyola", - "cps", - "cha", - "cityofchicago", - "columbia", - "ccc", - "moody", - "saic", - "npu", + 'depaul', + 'uchicago', + 'uic', + 'iit', + 'northwestern', + 'loyola', + 'cps', + 'cha', + 'cityofchicago', + 'columbia', + 'ccc', + 'moody', + 'saic', + 'npu', ]; module.exports = function (api) { @@ -50,7 +50,7 @@ module.exports = function (api) { BuildingOwnerIds.forEach((ownerId) => { createPage({ path: `/owner/${ownerId}`, - component: "./src/templates/BuildingOwner.vue", + component: './src/templates/BuildingOwner.vue', context: { ownerId }, }); }); @@ -65,7 +65,7 @@ module.exports = function (api) { function loadBuildingBenchmarkData(actions) { const latestBenchmarksRaw = readFileSync( `${DataDirectory}${BuildingEmissionsDataFile}`, - "utf8", + 'utf8', ); /** @@ -76,7 +76,7 @@ function loadBuildingBenchmarkData(actions) { skip_empty_lines: true, }); - const collection = actions.addCollection({ typeName: "Building" }); + const collection = actions.addCollection({ typeName: 'Building' }); for (const building of LatestBenchmarksData) { // Make a slugSource that is the property name or the address as a fallback (skip one letter @@ -86,8 +86,8 @@ function loadBuildingBenchmarkData(actions) { ? building.PropertyName : building.Address; - if (!building.slugSource || typeof building.slugSource !== "string") { - throw new Error("No building slug source (name or address)!", building); + if (!building.slugSource || typeof building.slugSource !== 'string') { + throw new Error('No building slug source (name or address)!', building); } collection.addNode(building); @@ -102,7 +102,7 @@ function loadBuildingBenchmarkData(actions) { function loadHistoricBenchmarkDat(actions) { const historicBenchmarksRaw = readFileSync( `${DataDirectory}${HistoricBenchmarkingDataFile}`, - "utf8", + 'utf8', ); /** @@ -113,7 +113,7 @@ function loadHistoricBenchmarkDat(actions) { skip_empty_lines: true, }); - const collection = actions.addCollection({ typeName: "Benchmark" }); + const collection = actions.addCollection({ typeName: 'Benchmark' }); for (const benchmark of HistoricBenchmarksData) { collection.addNode(benchmark); diff --git a/src/common-functions.vue b/src/common-functions.vue index ba78a0b5..204aa28f 100644 --- a/src/common-functions.vue +++ b/src/common-functions.vue @@ -77,17 +77,17 @@ export interface IHistoricData { export const RankConfig = { /** Buildings above this rank for a stat are marked very bad and get a 🚨 */ AlarmRankMax: 10, - AlarmEmoji: "🚨", + AlarmEmoji: '🚨', AlarmMsg: `Top 10 worst in at least one category`, /** Buildings above this rank for a stat are marked bad and get a 🚩 */ FlagRankMax: 50, - FlagEmoji: "🚩", + FlagEmoji: '🚩', FlagMsg: `Top 50 worst in at least one category`, /** Buildings with an _inverted rank_ at or under this get a 🏆 */ TrophyRankInvertedMax: 30, - TrophyEmoji: "🏆", + TrophyEmoji: '🏆', TrophyMsg: `Top 30 best in at least one category`, }; @@ -100,7 +100,7 @@ export function getRankLabel( isSquareFootage: boolean, ): string | null { if (isSquareFootage) { - return "Largest"; + return 'Largest'; } else if (statRank <= RankConfig.AlarmRankMax) { return `Highest in Chicago* ${RankConfig.AlarmEmoji}`; } else if (statRank <= RankConfig.FlagRankMax) { @@ -134,12 +134,12 @@ export function getRankLabelByProperty( * Columns that have rankings (format of _Rank and _PercentileRank) */ export const RankedColumns = [ - "GHGIntensity", - "TotalGHGEmissions", - "ElectricityUse", - "NaturalGasUse", - "SourceEUI", - "SiteEUI", + 'GHGIntensity', + 'TotalGHGEmissions', + 'ElectricityUse', + 'NaturalGasUse', + 'SourceEUI', + 'SiteEUI', // 'GrossFloorArea', ]; @@ -190,8 +190,8 @@ export function getOverallRankEmoji( // Loop through all ranked columns to get the worst emoji and whether any stats earn the building // a trophy RankedColumns.forEach((columnKey) => { - const val = building[columnKey + "Rank"]; - const statRank = parseFloat((val ?? "").toString()); + const val = building[columnKey + 'Rank']; + const statRank = parseFloat((val ?? '').toString()); const statRankInverted = getStatRankInverted( columnKey, statRank, @@ -199,7 +199,7 @@ export function getOverallRankEmoji( ); // Ignore the column if rank is NaN - if (typeof statRank !== "number" || isNaN(statRank)) { + if (typeof statRank !== 'number' || isNaN(statRank)) { return; } @@ -246,7 +246,7 @@ export function getOverallRankEmoji( export const UtilityCosts = { year: 2021, source: - "https://www.bls.gov/regions/midwest/news-release/AverageEnergyPrices_Chicago.htm", + 'https://www.bls.gov/regions/midwest/news-release/AverageEnergyPrices_Chicago.htm', electricCostPerKWh: 0.143, gasCostPerTherm: 1.192, }; diff --git a/src/components/BuildingImage.vue b/src/components/BuildingImage.vue index 392d2ec2..b5e22b85 100644 --- a/src/components/BuildingImage.vue +++ b/src/components/BuildingImage.vue @@ -9,7 +9,7 @@

Attribution: - {{ buildingImg.fromGoogleMaps ? "© Google " + currentYear : "" }} + {{ buildingImg.fromGoogleMaps ? '© Google ' + currentYear : '' }} Image Source diff --git a/src/components/EmailBuildingModal.vue b/src/components/EmailBuildingModal.vue index 9540dc29..2d66117c 100644 --- a/src/components/EmailBuildingModal.vue +++ b/src/components/EmailBuildingModal.vue @@ -61,9 +61,9 @@ diff --git a/src/components/OverallRankEmoji.vue b/src/components/OverallRankEmoji.vue index 4ea5e069..ca465a16 100644 --- a/src/components/OverallRankEmoji.vue +++ b/src/components/OverallRankEmoji.vue @@ -28,15 +28,15 @@ diff --git a/src/components/graphs/PieChart.vue b/src/components/graphs/PieChart.vue index d92eaa31..8ef63d42 100644 --- a/src/components/graphs/PieChart.vue +++ b/src/components/graphs/PieChart.vue @@ -5,8 +5,8 @@ diff --git a/src/components/layout/AppFooter.vue b/src/components/layout/AppFooter.vue index 83f1c7fe..2b4b654f 100644 --- a/src/components/layout/AppFooter.vue +++ b/src/components/layout/AppFooter.vue @@ -1,11 +1,11 @@ diff --git a/src/components/layout/AppHeader.vue b/src/components/layout/AppHeader.vue index d4d191de..54f5ab47 100644 --- a/src/components/layout/AppHeader.vue +++ b/src/components/layout/AppHeader.vue @@ -1,19 +1,19 @@