diff --git a/services/web/.eslintrc b/services/web/.eslintrc index a595e21a93..fdbf504c06 100644 --- a/services/web/.eslintrc +++ b/services/web/.eslintrc @@ -44,7 +44,6 @@ "no-prototype-builtins": "off", "no-var": "off", "prefer-const": "off", - "prefer-regex-literals": "off", "array-callback-return": "off", "no-unreachable-loop": "off", "no-loss-of-precision": "off", diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index f71de72ca8..f274018c90 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -258,7 +258,8 @@ module.exports = CompileController = { }, _getSafeProjectName(project) { - const safeProjectName = project.name.replace(new RegExp('\\W', 'g'), '_') + const wordRegExp = /\W/g + const safeProjectName = project.name.replace(wordRegExp, '_') return sanitize.escape(safeProjectName) }, diff --git a/services/web/app/src/Features/Project/SafePath.js b/services/web/app/src/Features/Project/SafePath.js index 94defafe73..f2e487bf64 100644 --- a/services/web/app/src/Features/Project/SafePath.js +++ b/services/web/app/src/Features/Project/SafePath.js @@ -20,6 +20,7 @@ const load = function () { let SafePath + // eslint-disable-next-line prefer-regex-literals const BADCHAR_RX = new RegExp( `\ [\ @@ -35,6 +36,7 @@ const load = function () { 'g' ) + // eslint-disable-next-line prefer-regex-literals const BADFILE_RX = new RegExp( `\ (^\\.$)\ @@ -52,6 +54,7 @@ const load = function () { // // The list of property names is taken from // ['prototype'].concat(Object.getOwnPropertyNames(Object.prototype)) + // eslint-disable-next-line prefer-regex-literals const BLOCKEDFILE_RX = new RegExp(`\ ^(\ prototype\ diff --git a/services/web/frontend/js/features/file-tree/util/safe-path.js b/services/web/frontend/js/features/file-tree/util/safe-path.js index d85953c7cd..c8950595eb 100644 --- a/services/web/frontend/js/features/file-tree/util/safe-path.js +++ b/services/web/frontend/js/features/file-tree/util/safe-path.js @@ -4,7 +4,7 @@ // app/src/Features/Project/SafePath.js // frontend/js/ide/directives/SafePath.js // frontend/js/features/file-tree/util/safe-path.js - +// eslint-disable-next-line prefer-regex-literals const BADCHAR_RX = new RegExp( `\ [\ @@ -19,7 +19,7 @@ const BADCHAR_RX = new RegExp( `, 'g' ) - +// eslint-disable-next-line prefer-regex-literals const BADFILE_RX = new RegExp( `\ (^\\.$)\ @@ -37,6 +37,7 @@ const BADFILE_RX = new RegExp( // // The list of property names is taken from // ['prototype'].concat(Object.getOwnPropertyNames(Object.prototype)) +// eslint-disable-next-line prefer-regex-literals const BLOCKEDFILE_RX = new RegExp(`\ ^(\ prototype\ diff --git a/services/web/frontend/js/features/outline/outline-parser.js b/services/web/frontend/js/features/outline/outline-parser.js index db57070715..80e3ec8e23 100644 --- a/services/web/frontend/js/features/outline/outline-parser.js +++ b/services/web/frontend/js/features/outline/outline-parser.js @@ -49,8 +49,8 @@ function matchOutline(content) { return flatOutline } -const DISPLAY_TITLE_REGEX = new RegExp('([^\\\\]*)\\\\([^{]+){([^}]+)}(.*)') -const END_OF_TITLE_REGEX = new RegExp('^([^{}]*?({[^{}]*?}[^{}]*?)*)}') +const DISPLAY_TITLE_REGEX = /([^\\]*)\\([^{]+){([^}]+)}(.*)/ +const END_OF_TITLE_REGEX = /^([^{}]*?({[^{}]*?}[^{}]*?)*)}/ /* * Attempt to improve the display of the outline title for titles with commands. * Either skip the command (for labels) or display the command's content instead diff --git a/services/web/frontend/js/ide/directives/SafePath.js b/services/web/frontend/js/ide/directives/SafePath.js index b43f2fcfb5..4d26383687 100644 --- a/services/web/frontend/js/ide/directives/SafePath.js +++ b/services/web/frontend/js/ide/directives/SafePath.js @@ -18,6 +18,7 @@ // frontend/js/features/file-tree/util/safe-path.js let SafePath +// eslint-disable-next-line prefer-regex-literals const BADCHAR_RX = new RegExp( `\ [\ @@ -33,6 +34,7 @@ const BADCHAR_RX = new RegExp( 'g' ) +// eslint-disable-next-line prefer-regex-literals const BADFILE_RX = new RegExp( `\ (^\\.$)\ @@ -50,6 +52,7 @@ const BADFILE_RX = new RegExp( // // The list of property names is taken from // ['prototype'].concat(Object.getOwnPropertyNames(Object.prototype)) +// eslint-disable-next-line prefer-regex-literals const BLOCKEDFILE_RX = new RegExp(`\ ^(\ prototype\ diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js index 42e392b868..ba3df6e9d1 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line prefer-regex-literals const BLACKLISTED_COMMAND_REGEX = new RegExp( `\ \\\\\ diff --git a/services/web/test/acceptance/src/ProjectInviteTests.js b/services/web/test/acceptance/src/ProjectInviteTests.js index c4ea9502d3..f426c02942 100644 --- a/services/web/test/acceptance/src/ProjectInviteTests.js +++ b/services/web/test/acceptance/src/ProjectInviteTests.js @@ -209,7 +209,7 @@ const expectInvitePage = (user, link, callback) => { tryFollowInviteLink(user, link, (err, response, body) => { expect(err).not.to.exist expect(response.statusCode).to.equal(200) - expect(body).to.match(new RegExp('Project Invite - .*')) + expect(body).to.match(/Project Invite - .*<\/title>/) callback() }) } @@ -219,7 +219,7 @@ const expectInvalidInvitePage = (user, link, callback) => { tryFollowInviteLink(user, link, (err, response, body) => { expect(err).not.to.exist expect(response.statusCode).to.equal(200) - expect(body).to.match(new RegExp('<title>Invalid Invite - .*')) + expect(body).to.match(/Invalid Invite - .*<\/title>/) callback() }) } @@ -229,7 +229,7 @@ const expectInviteRedirectToRegister = (user, link, callback) => { tryFollowInviteLink(user, link, (err, response) => { expect(err).not.to.exist expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.match(new RegExp('^/register.*$')) + expect(response.headers.location).to.match(/^\/register.*$/) callback() }) } @@ -238,7 +238,7 @@ const expectLoginPage = (user, callback) => { tryFollowLoginLink(user, '/login', (err, response, body) => { expect(err).not.to.exist expect(response.statusCode).to.equal(200) - expect(body).to.match(new RegExp('<title>Login - .*')) + expect(body).to.match(/Login - .*<\/title>/) callback() }) } diff --git a/services/web/test/acceptance/src/UserEmailsTests.js b/services/web/test/acceptance/src/UserEmailsTests.js index 80056c8319..c9cceacb24 100644 --- a/services/web/test/acceptance/src/UserEmailsTests.js +++ b/services/web/test/acceptance/src/UserEmailsTests.js @@ -937,7 +937,7 @@ describe('UserEmails', function () { expect(response.statusCode).to.equal(302) expect(response.headers) .to.have.property('location') - .to.match(new RegExp('^/login')) + .to.match(/^\/login/) done() } )