Skip to content

Commit

Permalink
Fix up xsslint to work
Browse files Browse the repository at this point in the history
This also moves us temporarily to a git branch version of xsslint until the
official package gets a new release with the appropriate fixes in place.

closes CORE-2125

Test Plan:
  - Automated tests pass
  - xsslint output shows that it linted many files

Change-Id: Id87e872dd2b7a08f11c0ddfaebdfc3f44e86c724
Reviewed-on: https://gerrit.instructure.com/171702
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <[email protected]>
QA-Review: Clay Diffrient <[email protected]>
Product-Review: Clay Diffrient <[email protected]>
  • Loading branch information
claydiffrient committed Nov 12, 2018
1 parent ce9a2ad commit 02fde29
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/coffeescripts/jquery/ModuleSequenceFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default class ModuleSequenceFooter {
this.next.url = masteryPath.modules_url
this.next.tooltipText = tooltipText
}
// xsslint safeString.property tooltipText
this.next.tooltip = `<i class='${htmlEscape(this.iconClasses.ModuleItem)}'/> ${this.next.tooltipText}`
}

Expand Down
5 changes: 4 additions & 1 deletion app/coffeescripts/widget/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export default class ComboBox {
this.$menu = $('select', this.$el)

// populate and instantiate the selectmenu
this.$menu.append(..._.map(this.items, this._buildOption))
const itemList = _.map(this.items, this._buildOption)
// We can't use a spread here because xsslint doesn't like it.
// xsslint safeString.identifier itemList
this.$menu.append.apply(this.$menu, itemList) // eslint-disable-line prefer-spread

// set initial selection
if (opts.selected != null) {
Expand Down
1 change: 1 addition & 0 deletions app/jsx/dashboard/DashboardHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DashboardHeader extends React.Component {
$dashboardActivity.show().disableWhileLoading(
Promise.all([promiseToGetCode, promiseToGetHtml])
.then(([DashboardView, axiosResponse]) => {
// xsslint safeString.property data
$dashboardActivity.html(axiosResponse.data)
new DashboardView()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// xsslint safeString.method I18n.t

import I18n from 'i18n!gradebook'
import htmlEscape from 'str/htmlEscape';
import { extractDataTurnitin } from 'compiled/gradezilla/Turnitin';
Expand Down Expand Up @@ -64,6 +66,7 @@ function renderStartContainer(options) {
content +=
'<div class="Grid__AssignmentRowCell__InvalidGrade"><i class="icon-warning"></i></div>'
}
// xsslint safeString.identifier content
return `<div class="Grid__AssignmentRowCell__StartContainer">${content}</div>`
}

Expand All @@ -85,9 +88,12 @@ function renderTemplate(grade, options = {}) {

if (options.turnitinState) {
classNames.push('turnitin');
// xsslint safeString.property turnitinState
content += `<span class="gradebook-cell-turnitin ${options.turnitinState}-score" />`;
}

// xsslint safeString.identifier content
// xsslint safeString.function renderStartContainer
return `<div class="${htmlEscape(classNames.join(' '))}">
${renderStartContainer(options)}
<div class="Grid__AssignmentRowCell__Content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function getGradePercentage (score, pointsPossible) {
function render (options) {
const percentage = options.possible ? options.percentage : '-';

// xsslint safeString.property score possible
// xsslint safeString.identifier percentage
return `
<div class="gradebook-cell">
<div class="gradebook-tooltip">${options.score} / ${options.possible}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ function getEnrollmentLabel (student) {
return null;
}

// xsslint safeString.property enrollmentLabel secondaryInfo studentId courseId url displayName
function render (options) {
let enrollmentStatus = '';
let secondaryInfo = '';

if (options.enrollmentLabel) {
const title = I18n.t('This user is currently not able to access the course');
// xsslint safeString.identifier title
enrollmentStatus = `&nbsp;<span title="${title}" class="label">${options.enrollmentLabel}</span>`;
}

if (options.secondaryInfo) {
secondaryInfo = `<div class="secondary-info">${options.secondaryInfo}</div>`;
}

// xsslint safeString.identifier enrollmentStatus secondaryInfo
return `
<div class="student-name">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function buildNoPointsPossibleWarning () {
};
}

// xsslint safeString.property score possbile warningText icon letterGrade
function render (options) {
let tooltip = '';
let warningIcon = '';
Expand All @@ -77,6 +78,7 @@ function render (options) {
tooltipContent = options.percentage;
}

// xsslint safeString.identifier tooltipContent
tooltip = `<div class="gradebook-tooltip">${tooltipContent}</div>`;
}

Expand All @@ -94,6 +96,7 @@ function render (options) {
letterGrade = `<span class="letter-grade-points">${options.letterGrade}</span>`;
}

// xsslint safeString.identifier tooltip warningIcon grade letterGrade
return `
<div class="gradebook-cell">
${tooltip}
Expand Down
1 change: 1 addition & 0 deletions app/jsx/outcomes/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import axios from 'axios'

export function createImport (contextRoot, file) {
const data = new FormData()
// xsslint safeString.identifier file
data.append('attachment', file)
const url = `/api/v1${contextRoot}/outcome_imports?import_type=instructure_csv`
return axios.post(url, data)
Expand Down
6 changes: 6 additions & 0 deletions app/jsx/theme_editor/ThemeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ export default class ThemeEditor extends React.Component {
Object.keys(properties).forEach(k => {
const defaultVal = this.getSchemaDefault(k)
if (properties[k] !== defaultVal && properties[k] && properties[k][0] !== '$') {
// xsslint safeString.identifier k properties[k]
// xsslint safeString.property k
processedData.append(`brand_config[variables][${k}]`, properties[k])
}
})
Expand All @@ -287,6 +289,8 @@ export default class ThemeEditor extends React.Component {
? f.variable_name
: `brand_config[variables][${f.variable_name}]`
if (!f.customFileUpload || (f.customFileUpload && f.value != null)) {
// xsslint safeString.identifier keyName
// xsslint safeString.property value
processedData.append(keyName, f.value)
}
})
Expand All @@ -297,6 +301,8 @@ export default class ThemeEditor extends React.Component {
processedData.get(name) === 'undefined' ||
processedData.get(name) === 'null'
) {
// xsslint safeString.identifier name
// xsslint safeString.property name
processedData.append(name, this.props.brandConfig[name] || '')
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"webpack-cleanup-plugin": "^0.5",
"webpack-manifest-plugin": "^2",
"wsrun": "^2.2.0",
"xsslint": "0.1.4",
"xsslint": "https://github.com/claydiffrient/xsslint.git#master",
"yaml-loader": "^0.5"
},
"jest-junit": {
Expand Down
9 changes: 4 additions & 5 deletions script/xsslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ const allPaths = [
transform: source => CoffeeScript.compile(source, {})
},
{
paths: ['app/jsx'].concat(glob.sync('gems/plugins/*/app/jsx')),
glob: '*.jsx'
paths: ['app/jsx', 'app/coffeescripts'].concat(glob.sync('gems/plugins/*/app/jsx')),
glob: '*.js'
},
{
paths: ['public/javascripts'].concat(glob.sync('gems/plugins/*/public/javascripts')),
Expand All @@ -114,7 +114,7 @@ const allPaths = [
}
]

allPaths.forEach(({paths, glob, defaultIgnores = [], transform}) => {
allPaths.forEach(({paths, glob, defaultIgnores = ['**/__tests__/**/*.js'], transform}) => {
paths.forEach(path => {
process.chdir(path)
const ignores = defaultIgnores.concat(
Expand All @@ -137,10 +137,9 @@ allPaths.forEach(({paths, glob, defaultIgnores = [], transform}) => {
let source = fs.readFileSync(file).toString()
if (transform) source = transform(source)
source = babylon.parse(source, {
plugins: ['jsx', 'classProperties', 'objectRestSpread'],
plugins: ['jsx', 'classProperties', 'objectRestSpread', 'dynamicImport'],
sourceType: 'module'
})

const warnings = XSSLint.run({source})
warningCount += warnings.length
warnings.forEach(({line, method}) => {
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18711,10 +18711,9 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"
integrity sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg==

xsslint@0.1.4:
"xsslint@https://github.com/claydiffrient/xsslint.git#master":
version "0.1.4"
resolved "https://registry.yarnpkg.com/xsslint/-/xsslint-0.1.4.tgz#1d4c5742d2f6076ae81ecced6c935375a8525114"
integrity sha1-HUxXQtL2B2roHsztbJNTdahSURQ=
resolved "https://github.com/claydiffrient/xsslint.git#f2a8ac8f2e7807da38ac99a0b8a6394c1e0769ee"
dependencies:
babel-traverse "^6.0.0"
babylon "^6.0.0"
Expand Down

0 comments on commit 02fde29

Please sign in to comment.