diff --git a/lib/rules/no-hide-core-modules.js b/lib/rules/no-hide-core-modules.js index 317919dc..01c0cb06 100644 --- a/lib/rules/no-hide-core-modules.js +++ b/lib/rules/no-hide-core-modules.js @@ -45,7 +45,7 @@ const CORE_MODULES = new Set([ "vm", "zlib", ]) -const BACK_SLASH = /\\/g +const BACK_SLASH = /\\/gu module.exports = { meta: { diff --git a/lib/rules/no-unpublished-bin.js b/lib/rules/no-unpublished-bin.js index 5744c23f..9db5436e 100644 --- a/lib/rules/no-unpublished-bin.js +++ b/lib/rules/no-unpublished-bin.js @@ -68,7 +68,7 @@ module.exports = { // Convert by convertPath option const basedir = path.dirname(p.filePath) const relativePath = getConvertPath(context)( - path.relative(basedir, rawFilePath).replace(/\\/g, "/") + path.relative(basedir, rawFilePath).replace(/\\/gu, "/") ) const filePath = path.join(basedir, relativePath) diff --git a/lib/rules/no-unsupported-features.js b/lib/rules/no-unsupported-features.js index 60c5afac..2b0cba0d 100644 --- a/lib/rules/no-unsupported-features.js +++ b/lib/rules/no-unsupported-features.js @@ -32,14 +32,14 @@ const VERSION_SCHEMA = { ], } const DEFAULT_VERSION = "4.0.0" -const FUNC_TYPE = /^(?:Arrow)?Function(?:Declaration|Expression)$/ -const CLASS_TYPE = /^Class(?:Declaration|Expression)$/ -const DESTRUCTURING_PARENT_TYPE = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression|AssignmentExpression|VariableDeclarator)$/ -const TOPLEVEL_SCOPE_TYPE = /^(?:global|function|module)$/ -const BINARY_NUMBER = /^0[bB]/ -const OCTAL_NUMBER = /^0[oO]/ -const UNICODE_ESC = /(\\+)u\{[0-9a-fA-F]+?\}/g -const GET_OR_SET = /^(?:g|s)et$/ +const FUNC_TYPE = /^(?:Arrow)?Function(?:Declaration|Expression)$/u +const CLASS_TYPE = /^Class(?:Declaration|Expression)$/u +const DESTRUCTURING_PARENT_TYPE = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression|AssignmentExpression|VariableDeclarator)$/u +const TOPLEVEL_SCOPE_TYPE = /^(?:global|function|module)$/u +const BINARY_NUMBER = /^0[bB]/u +const OCTAL_NUMBER = /^0[oO]/u +const UNICODE_ESC = /(\\+)u\{[0-9a-fA-F]+?\}/gu +const GET_OR_SET = /^(?:g|s)et$/u const NEW_BUILTIN_TYPES = [ "Int8Array", "Uint8Array", @@ -141,9 +141,9 @@ const PROPERTY_TEST_TARGETS = { "xor", ], } -const REGEXP_NAMED_GROUP = /(\\*)\(\?<[_$\w]/ -const REGEXP_LOOKBEHIND = /(\\*)\(\?<[=!]/ -const REGEXP_UNICODE_PROPERTY = /(\\*)\\[pP]{.+?}/ +const REGEXP_NAMED_GROUP = /(\\*)\(\?<[_$\w]/u +const REGEXP_LOOKBEHIND = /(\\*)\(\?<[=!]/u +const REGEXP_UNICODE_PROPERTY = /(\\*)\\[pP]\{.+?\}/u const FEATURES = { defaultParameters: { alias: ["syntax"], diff --git a/lib/rules/no-unsupported-features/es-syntax.js b/lib/rules/no-unsupported-features/es-syntax.js index b3453fd4..0f6a5169 100644 --- a/lib/rules/no-unsupported-features/es-syntax.js +++ b/lib/rules/no-unsupported-features/es-syntax.js @@ -10,7 +10,7 @@ const { Range } = require("semver") //eslint-disable-line no-unused-vars const getConfiguredNodeVersion = require("../../util/get-configured-node-version") const getSemverRange = require("../../util/get-semver-range") -const getOrSet = /^(?:g|s)et$/ +const getOrSet = /^(?:g|s)et$/u const features = { //-------------------------------------------------------------------------- // ES2015 diff --git a/lib/rules/shebang.js b/lib/rules/shebang.js index 9b269047..c65be87d 100644 --- a/lib/rules/shebang.js +++ b/lib/rules/shebang.js @@ -9,8 +9,8 @@ const getConvertPath = require("../util/get-convert-path") const getPackageJson = require("../util/get-package-json") const NODE_SHEBANG = "#!/usr/bin/env node\n" -const SHEBANG_PATTERN = /^(#!.+?)?(\r)?\n/ -const NODE_SHEBANG_PATTERN = /#!\/usr\/bin\/env node(?: [^\r\n]+?)?\n/ +const SHEBANG_PATTERN = /^(#!.+?)?(\r)?\n/u +const NODE_SHEBANG_PATTERN = /#!\/usr\/bin\/env node(?: [^\r\n]+?)?\n/u /** * Checks whether or not a given path is a `bin` file. @@ -89,7 +89,7 @@ module.exports = { filePath = path.join( basedir, getConvertPath(context)( - path.relative(basedir, filePath).replace(/\\/g, "/") + path.relative(basedir, filePath).replace(/\\/gu, "/") ) ) diff --git a/lib/util/check-publish.js b/lib/util/check-publish.js index 434427a7..004dde04 100644 --- a/lib/util/check-publish.js +++ b/lib/util/check-publish.js @@ -31,7 +31,7 @@ module.exports = function checkForPublish(context, filePath, targets) { const basedir = path.dirname(packageInfo.filePath) // eslint-disable-next-line func-style, require-jsdoc const toRelative = fullPath => { - const retv = path.relative(basedir, fullPath).replace(/\\/g, "/") + const retv = path.relative(basedir, fullPath).replace(/\\/gu, "/") return convertPath(retv) } const npmignore = getNpmignore(filePath) diff --git a/lib/util/exists.js b/lib/util/exists.js index 6cd39370..d57981b2 100644 --- a/lib/util/exists.js +++ b/lib/util/exists.js @@ -8,7 +8,7 @@ const fs = require("fs") const path = require("path") const Cache = require("./cache") -const ROOT = /^(?:[/.]|\.\.|[A-Z]:\\|\\\\)(?:[/\\]\.\.)*$/ +const ROOT = /^(?:[/.]|\.\.|[A-Z]:\\|\\\\)(?:[/\\]\.\.)*$/u const cache = new Cache() /** diff --git a/lib/util/get-convert-path.js b/lib/util/get-convert-path.js index b97582a0..4a56c309 100644 --- a/lib/util/get-convert-path.js +++ b/lib/util/get-convert-path.js @@ -109,7 +109,7 @@ function parse(option) { for (const pattern of normalizeValue(option.convertPath)) { const include = toStringArray(pattern.include) const exclude = toStringArray(pattern.exclude) - const fromRegexp = new RegExp(String(pattern.replace[0])) + const fromRegexp = new RegExp(String(pattern.replace[0])) //eslint-disable-line require-unicode-regexp const toStr = String(pattern.replace[1]) converters.push({ diff --git a/lib/util/get-import-export-targets.js b/lib/util/get-import-export-targets.js index 856d4c50..38d09769 100644 --- a/lib/util/get-import-export-targets.js +++ b/lib/util/get-import-export-targets.js @@ -11,7 +11,7 @@ const getTryExtensions = require("./get-try-extensions") const ImportTarget = require("./import-target") const stripImportPathParams = require("./strip-import-path-params") -const MODULE_TYPE = /^(?:Import|Export(?:Named|Default|All))Declaration$/ +const MODULE_TYPE = /^(?:Import|Export(?:Named|Default|All))Declaration$/u /** * Gets a list of `import`/`export` declaration targets. diff --git a/lib/util/get-npmignore.js b/lib/util/get-npmignore.js index 3cd1d02b..0e8699e6 100644 --- a/lib/util/get-npmignore.js +++ b/lib/util/get-npmignore.js @@ -12,9 +12,9 @@ const exists = require("./exists") const getPackageJson = require("./get-package-json") const cache = new Cache() -const SLASH_AT_BEGIN_AND_END = /^!?\/+|^!|\/+$/g -const PARENT_RELATIVE_PATH = /^\.\./ -const NEVER_IGNORED = /^(?:readme\.[^.]*|(?:licen[cs]e|changes|changelog|history)(?:\.[^.]*)?)$/i +const SLASH_AT_BEGIN_AND_END = /^!?\/+|^!|\/+$/gu +const PARENT_RELATIVE_PATH = /^\.\./u +const NEVER_IGNORED = /^(?:readme\.[^.]*|(?:licen[cs]e|changes|changelog|history)(?:\.[^.]*)?)$/iu /** * Checks whether or not a given file name is a relative path to a ancestor diff --git a/lib/util/import-target.js b/lib/util/import-target.js index d51ae4a0..c3834675 100644 --- a/lib/util/import-target.js +++ b/lib/util/import-target.js @@ -54,7 +54,7 @@ module.exports = class ImportTarget { * @param {object} options - The options of `node-resolve` module. */ constructor(node, name, options) { - const isModule = !/^(?:[./\\]|\w+:)/.test(name) + const isModule = !/^(?:[./\\]|\w+:)/u.test(name) /** * The node of a `require()` or a module declaraiton. diff --git a/scripts/update-readme.js b/scripts/update-readme.js index 24b28855..112abc0b 100644 --- a/scripts/update-readme.js +++ b/scripts/update-readme.js @@ -67,7 +67,7 @@ fs.writeFileSync( fs .readFileSync(filePath, "utf8") .replace( - /[\s\S]*/, + /[\s\S]*/u, `\n${content}\n` ) ) diff --git a/tests/lib/rules/process-exit-as-throw.js b/tests/lib/rules/process-exit-as-throw.js index 5b2e754f..6a1b11a7 100644 --- a/tests/lib/rules/process-exit-as-throw.js +++ b/tests/lib/rules/process-exit-as-throw.js @@ -37,9 +37,9 @@ describe("process-exit-as-throw", () => { const messages = linter.verify(code, options) - assert.equal(messages.length, 1) - assert.equal(messages[0].message, "Unreachable code.") - assert.equal(messages[0].line, 3) + assert.strictEqual(messages.length, 1) + assert.strictEqual(messages[0].message, "Unreachable code.") + assert.strictEqual(messages[0].line, 3) } ) ;(supported ? it : xit)( @@ -56,7 +56,7 @@ describe("process-exit-as-throw", () => { const messages = linter.verify(code, options) - assert.equal(messages.length, 0) + assert.strictEqual(messages.length, 0) } ) ;(supported ? it : xit)( @@ -81,7 +81,7 @@ describe("process-exit-as-throw", () => { const messages = linter.verify(code, options) - assert.equal(messages.length, 0) + assert.strictEqual(messages.length, 0) } ) })