From 752bbc6fe73a6ba75b38c67e4b7fec5a7b01a8c2 Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Mon, 16 Nov 2020 12:50:11 +0100 Subject: [PATCH] Remove @typescript-eslint/camelcase rule exception [MAILPOET-3201] --- .eslintrc.ts.json | 2 +- assets/js/src/announcements/with_feature_announcement.tsx | 6 +++++- assets/js/src/common/set_from_address_modal.tsx | 2 +- assets/js/src/mailpoet.js | 1 + assets/js/src/newsletters/campaign_stats/page.tsx | 2 +- assets/js/src/subscribers/stats.tsx | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.eslintrc.ts.json b/.eslintrc.ts.json index 49c62847a0..aa8982e03d 100644 --- a/.eslintrc.ts.json +++ b/.eslintrc.ts.json @@ -29,7 +29,6 @@ }, "rules": { "@typescript-eslint/await-thenable": "off", - "@typescript-eslint/camelcase": "off", "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-explicit-any": "off", // PropTypes @@ -39,6 +38,7 @@ "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "warn", // Exceptions + "@typescript-eslint/camelcase": ["error", { "properties": "never" }], // we need this to interact with the server "react/jsx-filename-extension": 0, "arrow-parens": ["error", "always"], "comma-dangle": ["error", "always-multiline"], diff --git a/assets/js/src/announcements/with_feature_announcement.tsx b/assets/js/src/announcements/with_feature_announcement.tsx index 469f1650d6..14d10e8ad3 100644 --- a/assets/js/src/announcements/with_feature_announcement.tsx +++ b/assets/js/src/announcements/with_feature_announcement.tsx @@ -26,9 +26,10 @@ export const withFeatureAnnouncement =

( } function updateLastAnnouncementSeenValue() { + // eslint-disable-next-line @typescript-eslint/camelcase const data = { last_announcement_seen: Math.floor(Date.now() / 1000) }; MailPoet.Ajax.post({ - api_version: (window as any).mailpoet_api_version, + api_version: MailPoet.apiVersion, endpoint: 'user_flags', action: 'set', data, @@ -36,7 +37,9 @@ export const withFeatureAnnouncement =

( } function loadBeamer() { + // eslint-disable-next-line @typescript-eslint/camelcase (window as any).beamer_config = { + // eslint-disable-next-line @typescript-eslint/camelcase product_id: 'VvHbhYWy7118', selector: '#beamer-empty-element', language: (window as any).mailpoet_user_locale, @@ -46,6 +49,7 @@ export const withFeatureAnnouncement =

( (window as any).beamer_config.filter = 'woocommerce'; } MailPoet.Modal.loading(true); + // eslint-disable-next-line @typescript-eslint/camelcase (window as any).mailpoet_feature_announcement_has_news = false; const s = document.createElement('script'); s.type = 'text/javascript'; diff --git a/assets/js/src/common/set_from_address_modal.tsx b/assets/js/src/common/set_from_address_modal.tsx index 9ac176b0bf..f27f2019b7 100644 --- a/assets/js/src/common/set_from_address_modal.tsx +++ b/assets/js/src/common/set_from_address_modal.tsx @@ -6,7 +6,7 @@ import Modal from 'common/modal/modal'; import { GlobalContext } from 'context'; import { noop } from 'lodash'; -const mailPoetApiVersion = (window as any).mailpoet_api_version as string; +const mailPoetApiVersion = MailPoet.apiVersion as string; /** * @param {string|null} address diff --git a/assets/js/src/mailpoet.js b/assets/js/src/mailpoet.js index c0280d3b9c..663eba11c4 100644 --- a/assets/js/src/mailpoet.js +++ b/assets/js/src/mailpoet.js @@ -17,6 +17,7 @@ var MailPoet = { hasValidApiKey: window.mailpoet_has_valid_api_key, listingPerPage: window.mailpoet_listing_per_page, libs3rdPartyEnabled: window.mailpoet_3rd_party_libs_enabled, + apiVersion: window.mailpoet_api_version, getShortcodeLinks: () => (window.mailpoet_shortcode_links ? window.mailpoet_shortcode_links : []), }; diff --git a/assets/js/src/newsletters/campaign_stats/page.tsx b/assets/js/src/newsletters/campaign_stats/page.tsx index e4fe5a6b04..1a3403f2c9 100644 --- a/assets/js/src/newsletters/campaign_stats/page.tsx +++ b/assets/js/src/newsletters/campaign_stats/page.tsx @@ -40,7 +40,7 @@ const CampaignStatsPage = ({ match, history, location }: Props) => { MailPoet.Modal.loading(true); MailPoet.Ajax.post({ - api_version: (window as any).mailpoet_api_version, + api_version: MailPoet.apiVersion, endpoint: (window as any).mailpoet_display_detailed_stats ? 'stats' : 'newsletters', action: (window as any).mailpoet_display_detailed_stats ? 'get' : 'getWithStats', data: { diff --git a/assets/js/src/subscribers/stats.tsx b/assets/js/src/subscribers/stats.tsx index 7476eddd22..8fb23b5e85 100644 --- a/assets/js/src/subscribers/stats.tsx +++ b/assets/js/src/subscribers/stats.tsx @@ -36,7 +36,7 @@ export const SubscriberStats = () => { useEffect(() => { MailPoet.Ajax.post({ - api_version: (window as any).mailpoet_api_version, + api_version: MailPoet.apiVersion, endpoint: 'subscriberStats', action: 'get', data: {