Update front-end linters and dependencies (#14644)

* Bump front-end dependencies

* Linting fixes for JS and SCSS files
This commit is contained in:
Alex Gibson 2024-06-17 04:30:45 +01:00 коммит произвёл GitHub
Родитель d83577cc77
Коммит e77c078b0b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
18 изменённых файлов: 259 добавлений и 470 удалений

Просмотреть файл

@ -79,17 +79,19 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
additional_dependencies:
- prettier@3.3.0
- repo: https://github.com/awebdeveloper/pre-commit-stylelint
rev: 0.0.2
hooks:
- id: stylelint
additional_dependencies:
- "stylelint@16.3.1"
- "stylelint@16.6.1"
- "stylelint-config-standard-scss@13.1.0"
- "postcss-scss@4.0.9"
- "postcss@8.4.38"
- repo: https://github.com/eslint/eslint
rev: v8.57.0
rev: v9.4.0
hooks:
- id: eslint
additional_dependencies:

Просмотреть файл

@ -41,7 +41,17 @@ const baseRules = {
// Disallow the use of `console`
// https://eslint.org/docs/rules/no-console
'no-console': 'error'
'no-console': 'error',
// Allow unused vars in caught errors for older
// browsers that don't support optional catch binding
// https://eslint.org/docs/latest/rules/no-unused-vars#options
'no-unused-vars': [
'error',
{
caughtErrors: 'none'
}
]
};
const extendedRules = {

Просмотреть файл

@ -21,13 +21,13 @@ $image-path: '/media/protocol/img';
}
.installer-channel-card {
margin: 0 auto $spacing-2xl auto;
margin: 0 auto $spacing-2xl;
float: none;
text-align: center;
}
.install-help {
margin: 0 auto $spacing-2xl auto;
margin: 0 auto $spacing-2xl;
max-width: $content-xs;
text-align: center;

Просмотреть файл

@ -448,7 +448,7 @@ $image-path: '/media/protocol/img';
color: $color-marketing-gray-60;
cursor: pointer;
font-weight: bold;
padding: 0 0 $spacing-xs 0;
padding: 0 0 $spacing-xs;
position: static;
&::before {

Просмотреть файл

@ -87,7 +87,7 @@ $image-path: '/media/protocol/img';
font-weight: bold;
height: 1.7em;
justify-content: center;
margin: 0 auto $spacing-md auto;
margin: 0 auto $spacing-md;
width: 1.7em;
}

Просмотреть файл

@ -57,8 +57,7 @@
.r25-promote-body {
@include text-body-xl;
background: transparent none;
border-image: none;
border: 0;
border: none;
grid-area: body;
margin: 0;
padding: 0;

Просмотреть файл

@ -62,7 +62,7 @@ $image-path: '/media/protocol/img';
max-width: 100%;
.footer-navigation-list-item {
margin: 0 $spacing-sm 0;
margin: 0 $spacing-sm;
}
}

Просмотреть файл

@ -193,7 +193,7 @@ $image-path: '/media/protocol/img';
));
.vpn-pricing-variable-saving {
margin: 0 0 $spacing-sm 0;
margin: 0 0 $spacing-sm;
}
}

Просмотреть файл

@ -33,7 +33,7 @@ html {
// Waitlist Feature Block
.vpn-waitlist-feature-block {
margin: 0 0 $layout-xl 0;
margin: 0 0 $layout-xl;
text-align: center;
.vpn-feature-list.mzp-u-list-styled {

Просмотреть файл

@ -4,8 +4,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
// eslint-disable-next-line
(function () {
'use strict';
var backLink = document.getElementById('go-back');

Просмотреть файл

@ -92,8 +92,6 @@
var utms = this.utmParams();
/* eslint-disable camelcase */
// set to default value if not specified in URL
if (!utms.utm_campaign) {
// utm_* values will be encoded on the product side, so no need to
@ -111,8 +109,6 @@
utms.utm_content = matches[1];
}
/* eslint-enable camelcase */
// ensure all values are strings, as no numeric values are allowed
// into UITour.showFirefoxAccounts
Object.keys(utms).forEach(function (key) {

Просмотреть файл

@ -117,14 +117,12 @@ if (typeof window.Mozilla === 'undefined') {
*/
StubAttribution.getCookie = function () {
return {
/* eslint-disable camelcase */
attribution_code: Mozilla.Cookies.getItem(
StubAttribution.COOKIE_CODE_ID
),
attribution_sig: Mozilla.Cookies.getItem(
StubAttribution.COOKIE_SIGNATURE_ID
)
/* eslint-enable camelcase */
};
};
@ -482,7 +480,6 @@ if (typeof window.Mozilla === 'undefined') {
? null
: StubAttribution.getGtagClientID();
/* eslint-disable camelcase */
var data = {
utm_source: utms.utm_source,
utm_medium: utms.utm_medium,
@ -500,7 +497,6 @@ if (typeof window.Mozilla === 'undefined') {
: null,
dlsource: StubAttribution.DLSOURCE
};
/* eslint-enable camelcase */
// Remove any undefined values.
for (var key in data) {

Просмотреть файл

@ -1,4 +1,3 @@
/* eslint-disable no-console */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this

595
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,7 +14,7 @@
"@mozmeao/trafficcop": "^3.0.0",
"@sentry/browser": "^8.8.0",
"babel-loader": "^9.1.3",
"caniuse-lite": "^1.0.30001627",
"caniuse-lite": "^1.0.30001628",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
@ -22,7 +22,7 @@
"mini-css-extract-plugin": "^2.9.0",
"sass": "^1.77.4",
"sass-loader": "^14.2.1",
"style-loader": "^3.3.4",
"style-loader": "^4.0.0",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
@ -39,14 +39,14 @@
"devDependencies": {
"concurrently": "^8.2.2",
"dotenv-webpack": "^8.1.0",
"eslint": "^8.57.0",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.3.0",
"jasmine-browser-runner": "^2.4.0",
"jasmine-core": "^5.1.2",
"prettier": "^3.2.5",
"sinon": "^17.0.1",
"stylelint": "^16.3.1",
"prettier": "^3.3.0",
"sinon": "^18.0.0",
"stylelint": "^16.6.1",
"stylelint-config-standard-scss": "^13.1.0",
"svgo": "^3.3.2",
"webpack-dev-server": "^5.0.4"

Просмотреть файл

@ -146,7 +146,6 @@ describe('fxa-form.js', function () {
spyOn(window.Mozilla.Client, '_isFirefoxDesktop').and.returnValue(
false
);
/* eslint-disable camelcase */
spyOn(FxaForm, 'getUTMParams').and.returnValue({
utm_source: 'desktop-snippet',
utm_content: 'rel-esr',
@ -154,7 +153,6 @@ describe('fxa-form.js', function () {
utm_term: 4242,
utm_campaign: 'F100_4242_otherstuff_in_here'
});
/* eslint-enable camelcase */
// Configure Sync for Firefox desktop before initializing attribution.
FxaForm.configureSync();
@ -205,7 +203,6 @@ describe('fxa-form.js', function () {
}
);
spyOn(window.Mozilla.UITour, 'showFirefoxAccounts');
/* eslint-disable camelcase */
spyOn(FxaForm, 'getUTMParams').and.returnValue({
utm_source: 'desktop-snippet',
utm_content: 'rel-esr',
@ -213,7 +210,6 @@ describe('fxa-form.js', function () {
utm_term: 4242,
utm_campaign: 'F100_4242_otherstuff_in_here'
});
/* eslint-enable camelcase */
// Configure Sync for Firefox desktop before initializing attribution.
FxaForm.configureSync();
@ -250,7 +246,6 @@ describe('fxa-form.js', function () {
);
form.querySelector('#fxa-email-form-submit').click();
/* eslint-disable camelcase */
expect(
window.Mozilla.UITour.showFirefoxAccounts
).toHaveBeenCalledWith(
@ -270,7 +265,6 @@ describe('fxa-form.js', function () {
'mozilla.org-privacy-products',
'a@a.com'
);
/* eslint-enable camelcase */
});
});
@ -288,7 +282,6 @@ describe('fxa-form.js', function () {
}
);
spyOn(window.Mozilla.UITour, 'showFirefoxAccounts');
/* eslint-disable camelcase */
spyOn(FxaForm, 'getUTMParams').and.returnValue({
utm_source: 'desktop-snippet',
utm_content: 'rel-esr',
@ -296,7 +289,6 @@ describe('fxa-form.js', function () {
utm_term: 4242,
utm_campaign: 'F100_4242_otherstuff_in_here'
});
/* eslint-enable camelcase */
// Configure Sync for Firefox desktop before initializing attribution.
FxaForm.configureSync();
@ -333,7 +325,6 @@ describe('fxa-form.js', function () {
);
form.querySelector('#fxa-email-form-submit').click();
/* eslint-disable camelcase */
expect(
window.Mozilla.UITour.showFirefoxAccounts
).toHaveBeenCalledWith(
@ -353,7 +344,6 @@ describe('fxa-form.js', function () {
'mozilla.org-privacy-products',
'a@a.com'
);
/* eslint-enable camelcase */
});
});

Просмотреть файл

@ -87,12 +87,10 @@ describe('fxa-link.js', function () {
window.Mozilla.UITour.showFirefoxAccounts
).toHaveBeenCalledWith(
{
/* eslint-disable camelcase */
utm_source: 'mozilla.org-firefoxnav',
utm_campaign: 'nav',
utm_content: 'join-sign-in',
utm_medium: 'referral'
/* eslint-enable camelcase */
},
'mozilla.org-firefoxnav'
);
@ -140,7 +138,6 @@ describe('fxa-link.js', function () {
window.Mozilla.UITour.showFirefoxAccounts
).toHaveBeenCalledWith(
{
/* eslint-disable camelcase */
flow_id: 'flow',
flow_begin_time: '100',
device_id: 'dev',
@ -150,7 +147,6 @@ describe('fxa-link.js', function () {
utm_campaign: 'nav',
utm_content: 'join-sign-in',
utm_medium: 'referral'
/* eslint-enable camelcase */
},
'mozilla.org-firefoxnav'
);

Просмотреть файл

@ -28,7 +28,6 @@ describe('stub-attribution.js', function () {
let data = {};
beforeEach(function () {
/* eslint-disable camelcase */
data = {
utm_source: 'desktop-snippet',
utm_medium: 'referral',
@ -40,7 +39,6 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
spyOn(Mozilla.StubAttribution, 'requestAuthentication');
spyOn(Mozilla.StubAttribution, 'updateBouncerLinks');
@ -56,12 +54,10 @@ describe('stub-attribution.js', function () {
});
it('should update download links if session cookie exists', function () {
/* eslint-disable camelcase */
const cookieData = {
attribution_code: 'foo',
attribution_sig: 'bar'
};
/* eslint-enable camelcase */
spyOn(
Mozilla.StubAttribution,
'withinAttributionRate'
@ -275,7 +271,6 @@ describe('stub-attribution.js', function () {
describe('hasValidData', function () {
it('should return true for valid attribution data', function () {
/* eslint-disable camelcase */
const data = {
utm_source: 'desktop-snippet',
utm_medium: 'referral',
@ -287,13 +282,11 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data)).toBeTruthy();
});
it('should return true for valid RTAMO data', function () {
/* eslint-disable camelcase */
const data = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -305,11 +298,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data)).toBeTruthy();
/* eslint-disable camelcase */
const data2 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -321,11 +312,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data2)).toBeTruthy();
/* eslint-disable camelcase */
const data3 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -337,11 +326,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data3)).toBeTruthy();
/* eslint-disable camelcase */
const data4 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -353,13 +340,11 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data4)).toBeTruthy();
});
it('should return false for RTAMO data that does not have AMO as the referrer', function () {
/* eslint-disable camelcase */
const data = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -371,11 +356,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data)).toBeFalsy();
/* eslint-disable camelcase */
const data2 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -387,11 +370,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data2)).toBeFalsy();
/* eslint-disable camelcase */
const data3 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -403,11 +384,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data3)).toBeFalsy();
/* eslint-disable camelcase */
const data4 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -419,13 +398,11 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data4)).toBeFalsy();
});
it('should return false if utm_content is too long', function () {
/* eslint-disable camelcase */
const data1 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -439,11 +416,9 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data1)).toBeFalsy();
/* eslint-disable camelcase */
const data2 = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -457,13 +432,11 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data2)).toBeFalsy();
});
it('should return false for RTAMO data if referrer is not set', function () {
/* eslint-disable camelcase */
const data = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -475,7 +448,6 @@ describe('stub-attribution.js', function () {
client_id_ga4: GA4_CLIENT_ID,
session_id: STUB_SESSION_ID
};
/* eslint-enable camelcase */
expect(Mozilla.StubAttribution.hasValidData(data)).toBeFalsy();
});
@ -626,16 +598,13 @@ describe('stub-attribution.js', function () {
it('should return attribution data if utm params are present', function () {
const referrer = '';
/* eslint-disable camelcase */
const utms = {
utm_source: 'desktop-snippet',
utm_medium: 'referral',
utm_campaign: 'F100_4242_otherstuff_in_here',
utm_content: 'rel-esr'
};
/* eslint-enable camelcase */
/* eslint-disable camelcase */
const data = {
utm_source: 'desktop-snippet',
utm_medium: 'referral',
@ -648,7 +617,6 @@ describe('stub-attribution.js', function () {
session_id: jasmine.any(String),
dlsource: DLSOURCE
};
/* eslint-enable camelcase */
spyOn(window._SearchParams.prototype, 'utmParams').and.returnValue(
utms
@ -663,16 +631,13 @@ describe('stub-attribution.js', function () {
it('should return attribution data if referrer is present', function () {
const referrer = 'https://www.mozilla.org/en-US/';
/* eslint-disable camelcase */
const utms = {
utm_source: undefined,
utm_medium: undefined,
utm_campaign: undefined,
utm_content: undefined
};
/* eslint-enable camelcase */
/* eslint-disable camelcase */
const data = {
referrer: 'https://www.mozilla.org/en-US/',
ua: 'chrome',
@ -681,7 +646,6 @@ describe('stub-attribution.js', function () {
session_id: jasmine.any(String),
dlsource: DLSOURCE
};
/* eslint-enable camelcase */
spyOn(window._SearchParams.prototype, 'utmParams').and.returnValue(
utms
@ -696,16 +660,13 @@ describe('stub-attribution.js', function () {
it('should return only generic data if neither utm params and referrer are present', function () {
const referrer = '';
/* eslint-disable camelcase */
const utms = {
utm_source: undefined,
utm_medium: undefined,
utm_campaign: undefined,
utm_content: undefined
};
/* eslint-enable camelcase */
/* eslint-disable camelcase */
const data = {
referrer: '',
ua: 'chrome',
@ -714,7 +675,6 @@ describe('stub-attribution.js', function () {
session_id: jasmine.any(String),
dlsource: DLSOURCE
};
/* eslint-enable camelcase */
spyOn(window._SearchParams.prototype, 'utmParams').and.returnValue(
utms
@ -729,16 +689,13 @@ describe('stub-attribution.js', function () {
it('should return optional experimental parameters if present', function () {
const referrer = '';
/* eslint-disable camelcase */
const utms = {
utm_source: undefined,
utm_medium: undefined,
utm_campaign: undefined,
utm_content: undefined
};
/* eslint-enable camelcase */
/* eslint-disable camelcase */
const data = {
referrer: '',
ua: 'chrome',
@ -749,7 +706,6 @@ describe('stub-attribution.js', function () {
session_id: jasmine.any(String),
dlsource: DLSOURCE
};
/* eslint-enable camelcase */
spyOn(window._SearchParams.prototype, 'utmParams').and.returnValue(
utms
@ -769,16 +725,13 @@ describe('stub-attribution.js', function () {
it('should omit non-essential attribution data when `omitNonEssentialFields=true` is passed', function () {
const referrer = 'https://addons.mozilla.org/';
/* eslint-disable camelcase */
const utms = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
utm_campaign: 'non-fx-button',
utm_content: 'rta%3Acm9uaW4td2FsbGV0QGF4aWVpbmZpbml0eS5jb20'
};
/* eslint-enable camelcase */
/* eslint-disable camelcase */
const data = {
utm_source: 'addons.mozilla.org',
utm_medium: 'referral',
@ -788,7 +741,6 @@ describe('stub-attribution.js', function () {
ua: 'other',
dlsource: DLSOURCE
};
/* eslint-enable camelcase */
spyOn(window._SearchParams.prototype, 'utmParams').and.returnValue(
utms
@ -830,12 +782,10 @@ describe('stub-attribution.js', function () {
});
it('should handle a request successfully', function () {
/* eslint-disable camelcase */
const data = {
attribution_code: 'foo',
attribution_sig: 'bar'
};
/* eslint-enable camelcase */
const callback = function () {}; // eslint-disable-line no-empty-function
Mozilla.StubAttribution.successCallback = callback;
@ -892,12 +842,10 @@ describe('stub-attribution.js', function () {
});
it('should handle the data as expected', function () {
/* eslint-disable camelcase */
const data = {
attribution_code: 'foo',
attribution_sig: 'bar'
};
/* eslint-enable camelcase */
spyOn(Mozilla.StubAttribution, 'updateBouncerLinks');
spyOn(Mozilla.StubAttribution, 'setCookie');
@ -912,12 +860,10 @@ describe('stub-attribution.js', function () {
});
it('should only handle the request once', function () {
/* eslint-disable camelcase */
const data = {
attribution_code: 'foo',
attribution_sig: 'bar'
};
/* eslint-enable camelcase */
spyOn(Mozilla.StubAttribution, 'updateBouncerLinks');
spyOn(Mozilla.StubAttribution, 'setCookie');
@ -931,12 +877,10 @@ describe('stub-attribution.js', function () {
});
describe('updateBouncerLinks', function () {
/* eslint-disable camelcase */
const data = {
attribution_code: 'test-code',
attribution_sig: 'test-sig'
};
/* eslint-enable camelcase */
const winUrl =
'https://download.mozilla.org/?product=firefox-latest-ssl&os=win&lang=en-US';
@ -1096,14 +1040,12 @@ describe('stub-attribution.js', function () {
let expectedUrl = '';
beforeEach(function () {
/* eslint-disable camelcase */
params = {
attribution_code:
'source%3Dbrandt%26medium%3Daether%26campaign%3D%28not+set%29%26content%3D%28not+set%29%26timestamp%3D1478181983',
attribution_sig:
'241c4ef87bd2554154c5658d99230660d4c242abbe1ac87b89ac0e9dd56b2f4e'
};
/* eslint-enable camelcase */
originalUrl =
'https://download.mozilla.org/?product=firefox-stub&os=win&lang=en-US';
@ -1139,12 +1081,10 @@ describe('stub-attribution.js', function () {
? 'foo'
: 'bar';
});
/* eslint-disable camelcase */
expect(Mozilla.StubAttribution.getCookie()).toEqual({
attribution_code: 'foo',
attribution_sig: 'bar'
});
/* eslint-enable camelcase */
expect(Mozilla.Cookies.getItem.calls.count()).toEqual(2);
});
});
@ -1155,12 +1095,10 @@ describe('stub-attribution.js', function () {
});
it('should set session cookies as expected', function () {
/* eslint-disable camelcase */
const data = {
attribution_code: 'foo',
attribution_sig: 'bar'
};
/* eslint-enable camelcase */
Mozilla.StubAttribution.setCookie(data);
expect(Mozilla.Cookies.setItem.calls.count()).toEqual(2);