mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #3950 from overleaf/msm-reenable-lint-prefer-regex-literals
Reenable `prefer-regex-literals` eslint rule GitOrigin-RevId: 3c576d92a08dfcb745d447b1bf8c7b828753010d
This commit is contained in:
parent
72af966c9c
commit
adfde7d26b
9 changed files with 19 additions and 11 deletions
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
},
|
||||
|
||||
|
|
|
@ -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\
|
||||
|
|
|
@ -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\
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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\
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line prefer-regex-literals
|
||||
const BLACKLISTED_COMMAND_REGEX = new RegExp(
|
||||
`\
|
||||
\\\\\
|
||||
|
|
|
@ -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('<title>Project Invite - .*</title>'))
|
||||
expect(body).to.match(/<title>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 - .*</title>'))
|
||||
expect(body).to.match(/<title>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 - .*</title>'))
|
||||
expect(body).to.match(/<title>Login - .*<\/title>/)
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue