build: update stylint and eslint thresholds (#29471)
* build: update stylint and eslint thresholds * Removed stylint threshold * Update test_stylelint.py * fix: fix eslint issues
This commit is contained in:
committed by
GitHub
parent
5de4264c84
commit
8320dcb0e8
@@ -1,5 +1,5 @@
|
||||
/* globals $ */
|
||||
import 'jquery.cookie';
|
||||
import 'jquery.cookie'; // eslint-disable-line
|
||||
import gettext from 'gettext'; // eslint-disable-line
|
||||
import { clampHtmlByWords } from 'common/js/utils/clamp-html'; // eslint-disable-line
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
self.trigger('search');
|
||||
},
|
||||
error: function(self, response) {
|
||||
self.errorMessage = self.extractErrorMessage(response);
|
||||
self.errorMessage = self.extractErrorMessage(response); // eslint-disable-line no-param-reassign
|
||||
self.trigger('error');
|
||||
}
|
||||
});
|
||||
@@ -78,7 +78,7 @@
|
||||
self.trigger('next');
|
||||
},
|
||||
error: function(self, response) {
|
||||
self.errorMessage = self.extractErrorMessage(response);
|
||||
self.errorMessage = self.extractErrorMessage(response); // eslint-disable-line no-param-reassign
|
||||
self.trigger('error');
|
||||
},
|
||||
add: true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function(define) {
|
||||
(function (define){
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
@@ -19,19 +19,19 @@
|
||||
'js/student_account/views/account_settings_fields',
|
||||
'js/views/message_banner',
|
||||
'string_utils'
|
||||
], function(gettext, $, _, Backbone, Logger, StringUtils, PagingCollection, AccountSettingsModel,
|
||||
AccountPreferencesModel, FieldsView, LearnerProfileFieldsView, LearnerProfileView, BadgeModel,
|
||||
BadgeListContainer, AccountSettingsFieldViews, MessageBannerView) {
|
||||
return function(options) {
|
||||
], function (gettext, $, _, Backbone, Logger, StringUtils, PagingCollection, AccountSettingsModel,
|
||||
AccountPreferencesModel, FieldsView, LearnerProfileFieldsView, LearnerProfileView, BadgeModel,
|
||||
BadgeListContainer, AccountSettingsFieldViews, MessageBannerView){
|
||||
return function (options) {
|
||||
var $learnerProfileElement = $('.wrapper-profile');
|
||||
|
||||
var accountSettingsModel = new AccountSettingsModel(
|
||||
_.extend(
|
||||
options.account_settings_data,
|
||||
{
|
||||
default_public_account_fields: options.default_public_account_fields,
|
||||
parental_consent_age_limit: options.parental_consent_age_limit,
|
||||
enable_coppa_compliance: options.enable_coppa_compliance
|
||||
default_public_account_fields: options.default_public_account_fields,
|
||||
parental_consent_age_limit: options.parental_consent_age_limit,
|
||||
enable_coppa_compliance: options.enable_coppa_compliance
|
||||
}
|
||||
),
|
||||
{parse: true}
|
||||
@@ -208,7 +208,7 @@
|
||||
platformName: options.platform_name
|
||||
});
|
||||
|
||||
getProfileVisibility = function() {
|
||||
getProfileVisibility = function (){
|
||||
if (options.has_preferences_access) {
|
||||
return accountPreferencesModel.get('account_privacy');
|
||||
} else {
|
||||
@@ -216,7 +216,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
showLearnerProfileView = function() {
|
||||
showLearnerProfileView = function (){
|
||||
// Record that the profile page was viewed
|
||||
Logger.log('edx.user.settings.viewed', {
|
||||
page: 'profile',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function(define) {
|
||||
(function (define){
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
@@ -7,10 +7,10 @@
|
||||
'common/js/components/views/tabbed_view',
|
||||
'learner_profile/js/views/section_two_tab'
|
||||
],
|
||||
function(gettext, $, _, Backbone, HtmlUtils, TabbedView, SectionTwoTab) {
|
||||
function (gettext, $, _, Backbone, HtmlUtils, TabbedView, SectionTwoTab){
|
||||
var LearnerProfileView = Backbone.View.extend({
|
||||
|
||||
initialize: function(options) {
|
||||
initialize: function (options){
|
||||
var Router;
|
||||
this.options = _.extend({}, options);
|
||||
_.bindAll(this, 'showFullProfile', 'render', 'renderFields', 'showLoadingError');
|
||||
@@ -23,7 +23,7 @@
|
||||
this.firstRender = true;
|
||||
},
|
||||
|
||||
showFullProfile: function() {
|
||||
showFullProfile: function () {
|
||||
var isAboveMinimumAge = this.options.accountSettingsModel.isAboveMinimumAge();
|
||||
if (this.options.ownProfile) {
|
||||
return isAboveMinimumAge
|
||||
@@ -33,14 +33,14 @@
|
||||
}
|
||||
},
|
||||
|
||||
setActiveTab: function(tab) {
|
||||
setActiveTab: function (tab){
|
||||
// This tab may not actually exist.
|
||||
if (this.tabbedView.getTabMeta(tab).tab) {
|
||||
this.tabbedView.setActiveTab(tab);
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
render: function (){
|
||||
var tabs,
|
||||
$tabbedViewElement,
|
||||
$wrapperProfileBioElement = this.$el.find('.wrapper-profile-bio'),
|
||||
@@ -77,9 +77,9 @@
|
||||
];
|
||||
|
||||
// Build the accomplishments Tab and fill with data
|
||||
this.options.badgeListContainer.collection.fetch().done(function() {
|
||||
this.options.badgeListContainer.collection.fetch().done(function (){
|
||||
self.options.badgeListContainer.render();
|
||||
}).error(function() {
|
||||
}).error(function (){
|
||||
self.options.badgeListContainer.renderError();
|
||||
});
|
||||
|
||||
@@ -107,20 +107,21 @@
|
||||
Backbone.history.start();
|
||||
}
|
||||
} else {
|
||||
if(this.isCoppaCompliant())
|
||||
if (this.isCoppaCompliant()) {
|
||||
// xss-lint: disable=javascript-jquery-html
|
||||
$wrapperProfileBioElement.html(this.sectionTwoView.render().el);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
isCoppaCompliant: function() {
|
||||
var enableCoppaCompliance = this.options.accountSettingsModel.get('enable_coppa_compliance'),
|
||||
isAboveAge = this.options.accountSettingsModel.isAboveMinimumAge();
|
||||
return !enableCoppaCompliance || (enableCoppaCompliance && isAboveAge);
|
||||
isCoppaCompliant: function (){
|
||||
var enableCoppaCompliance = this.options.accountSettingsModel.get('enable_coppa_compliance'),
|
||||
isAboveAge = this.options.accountSettingsModel.isAboveMinimumAge();
|
||||
return !enableCoppaCompliance || (enableCoppaCompliance && isAboveAge);
|
||||
},
|
||||
|
||||
renderFields: function() {
|
||||
renderFields: function (){
|
||||
var view = this,
|
||||
fieldView,
|
||||
imageView,
|
||||
@@ -149,14 +150,14 @@
|
||||
imageView = this.options.profileImageFieldView;
|
||||
this.$('.profile-image-field').append(imageView.render().el);
|
||||
|
||||
if (this.showFullProfile()) {
|
||||
_.each(this.options.sectionOneFieldViews, function(childFieldView) {
|
||||
if (this.showFullProfile()){
|
||||
_.each(this.options.sectionOneFieldViews, function (childFieldView) {
|
||||
view.$('.profile-section-one-fields').append(childFieldView.render().el);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
showLoadingError: function() {
|
||||
showLoadingError: function (){
|
||||
this.$('.ui-loading-indicator').addClass('is-hidden');
|
||||
this.$('.ui-loading-error').removeClass('is-hidden');
|
||||
}
|
||||
|
||||
@@ -17,19 +17,20 @@ class TestPaverStylelint(PaverTestCase):
|
||||
Tests for Paver's Stylelint tasks.
|
||||
"""
|
||||
@ddt.data(
|
||||
[0, False],
|
||||
[99, False],
|
||||
[100, True],
|
||||
[False],
|
||||
[True],
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_run_stylelint(self, violations_limit, should_pass):
|
||||
def test_run_stylelint(self, should_pass):
|
||||
"""
|
||||
Verify that the quality task fails with Stylelint violations.
|
||||
"""
|
||||
_mock_stylelint_violations = MagicMock(return_value=100)
|
||||
with patch('pavelib.quality._get_stylelint_violations', _mock_stylelint_violations):
|
||||
if should_pass:
|
||||
call_task('pavelib.quality.run_stylelint', options={"limit": violations_limit})
|
||||
else:
|
||||
if should_pass:
|
||||
_mock_stylelint_violations = MagicMock(return_value=0)
|
||||
with patch('pavelib.quality._get_stylelint_violations', _mock_stylelint_violations):
|
||||
call_task('pavelib.quality.run_stylelint')
|
||||
else:
|
||||
_mock_stylelint_violations = MagicMock(return_value=100)
|
||||
with patch('pavelib.quality._get_stylelint_violations', _mock_stylelint_violations):
|
||||
with pytest.raises(SystemExit):
|
||||
call_task('pavelib.quality.run_stylelint', options={"limit": violations_limit})
|
||||
call_task('pavelib.quality.run_stylelint')
|
||||
|
||||
@@ -375,14 +375,14 @@ def run_stylelint(options):
|
||||
Runs stylelint on Sass files.
|
||||
If limit option is passed, fails build if more violations than the limit are found.
|
||||
"""
|
||||
violations_limit = int(getattr(options, 'limit', -1))
|
||||
violations_limit = 0
|
||||
num_violations = _get_stylelint_violations()
|
||||
|
||||
# Record the metric
|
||||
_write_metric(num_violations, (Env.METRICS_DIR / "stylelint"))
|
||||
|
||||
# Fail if number of violations is greater than the limit
|
||||
if num_violations > violations_limit > -1:
|
||||
if num_violations > violations_limit:
|
||||
fail_quality(
|
||||
'stylelint',
|
||||
"FAILURE: Stylelint failed with too many violations: ({count}).\nThe limit is {violations_limit}.".format(
|
||||
|
||||
@@ -11,7 +11,7 @@ but ignore other databases.
|
||||
|
||||
|
||||
String.prototype.startsWith = function(substring) {
|
||||
return (this.indexOf(substring) == 0);
|
||||
return (this.indexOf(substring) === 0);
|
||||
};
|
||||
|
||||
var dbNameList = db.getMongo().getDBNames();
|
||||
|
||||
@@ -131,7 +131,7 @@ case "$TEST_SUITE" in
|
||||
echo "Finding ESLint violations and storing report..."
|
||||
run_paver_quality run_eslint -l $ESLINT_THRESHOLD || { EXIT=1; }
|
||||
echo "Finding Stylelint violations and storing report..."
|
||||
run_paver_quality run_stylelint -l $STYLELINT_THRESHOLD || { EXIT=1; }
|
||||
run_paver_quality run_stylelint || { EXIT=1; }
|
||||
echo "Running xss linter report."
|
||||
run_paver_quality run_xsslint -t $XSSLINT_THRESHOLDS || { EXIT=1; }
|
||||
if [[ ! -z "$TARGET_BRANCH" ]]; then
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
export ESLINT_THRESHOLD=5300
|
||||
export STYLELINT_THRESHOLD=880
|
||||
export ESLINT_THRESHOLD=4950
|
||||
|
||||
Reference in New Issue
Block a user