Skip to content

Commit fcafb61

Browse files
authored
fix: add missing 'use strict' directives (#780)
<!-- What / Why --> <!-- Describe the request in detail. What it does and why it's being changed. --> Adds missing `'use strict'` directives; this directive is dotted around a handful of files in the repo so this PR adds it to the rest of the CJS files. The local eslint file has been updated to enforce this going forward, as suggested in the linked issue. ## References Closes #774 <!-- Examples: Related to #0 Depends on #0 Blocked by #0 Fixes #0 Closes #0 -->
1 parent c760403 commit fcafb61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+236
-0
lines changed

.eslintrc.local.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
},
1313
],
1414
'import/no-nodejs-modules': ['error'],
15+
strict: ['error', 'global'],
1516
},
1617
},
1718
],

benchmarks/bench-compare.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const SemVer = require('../classes/semver')
35
const suite = new Benchmark.Suite()

benchmarks/bench-diff.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const diff = require('../functions/diff')
35
const suite = new Benchmark.Suite()

benchmarks/bench-parse-options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const parseOptions = require('../internal/parse-options')
35
const suite = new Benchmark.Suite()

benchmarks/bench-parse.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const parse = require('../functions/parse')
35
const { MAX_SAFE_INTEGER } = require('../internal/constants')

benchmarks/bench-satisfies.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const satisfies = require('../functions/satisfies')
35
const suite = new Benchmark.Suite()

benchmarks/bench-subset.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Benchmark = require('benchmark')
24
const subset = require('../ranges/subset')
35
const suite = new Benchmark.Suite()

bin/semver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Exits successfully and prints matching version(s) if
44
// any supplied version is valid and passes all tests.
55

6+
'use strict'
7+
68
const argv = process.argv.slice(2)
79

810
let versions = []

classes/comparator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const ANY = Symbol('SemVer ANY')
24
// hoisted class for cyclic dependency
35
class Comparator {

classes/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
module.exports = {
24
SemVer: require('./semver.js'),
35
Range: require('./range.js'),

classes/range.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SPACE_CHARACTERS = /\s+/g
24

35
// hoisted class for cyclic dependency

classes/semver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const debug = require('../internal/debug')
24
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
35
const { safeRe: re, t } = require('../internal/re')

functions/clean.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const parse = require('./parse')
24
const clean = (version, options) => {
35
const s = parse(version.trim().replace(/^[=v]+/, ''), options)

functions/cmp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const eq = require('./eq')
24
const neq = require('./neq')
35
const gt = require('./gt')

functions/coerce.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const parse = require('./parse')
35
const { safeRe: re, t } = require('../internal/re')

functions/compare-build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const compareBuild = (a, b, loose) => {
35
const versionA = new SemVer(a, loose)

functions/compare-loose.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const compareLoose = (a, b) => compare(a, b, true)
35
module.exports = compareLoose

functions/compare.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const compare = (a, b, loose) =>
35
new SemVer(a, loose).compare(new SemVer(b, loose))

functions/diff.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const parse = require('./parse.js')
24

35
const diff = (version1, version2) => {

functions/eq.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const eq = (a, b, loose) => compare(a, b, loose) === 0
35
module.exports = eq

functions/gt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const gt = (a, b, loose) => compare(a, b, loose) > 0
35
module.exports = gt

functions/gte.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const gte = (a, b, loose) => compare(a, b, loose) >= 0
35
module.exports = gte

functions/inc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24

35
const inc = (version, release, options, identifier, identifierBase) => {

functions/lt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const lt = (a, b, loose) => compare(a, b, loose) < 0
35
module.exports = lt

functions/lte.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const lte = (a, b, loose) => compare(a, b, loose) <= 0
35
module.exports = lte

functions/major.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const major = (a, loose) => new SemVer(a, loose).major
35
module.exports = major

functions/minor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const minor = (a, loose) => new SemVer(a, loose).minor
35
module.exports = minor

functions/neq.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const neq = (a, b, loose) => compare(a, b, loose) !== 0
35
module.exports = neq

functions/parse.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const parse = (version, options, throwErrors = false) => {
35
if (version instanceof SemVer) {

functions/patch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const patch = (a, loose) => new SemVer(a, loose).patch
35
module.exports = patch

functions/prerelease.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const parse = require('./parse')
24
const prerelease = (version, options) => {
35
const parsed = parse(version, options)

functions/rcompare.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compare = require('./compare')
24
const rcompare = (a, b, loose) => compare(b, a, loose)
35
module.exports = rcompare

functions/rsort.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compareBuild = require('./compare-build')
24
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
35
module.exports = rsort

functions/satisfies.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Range = require('../classes/range')
24
const satisfies = (version, range, options) => {
35
try {

functions/sort.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const compareBuild = require('./compare-build')
24
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
35
module.exports = sort

functions/valid.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const parse = require('./parse')
24
const valid = (version, options) => {
35
const v = parse(version, options)

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// just pre-load all the stuff that index.js lazily exports
24
const internalRe = require('./internal/re')
35
const constants = require('./internal/constants')

internal/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// Note: this is the semver.org version of the spec that it implements
24
// Not necessarily the package version of this code.
35
const SEMVER_SPEC_VERSION = '2.0.0'

internal/debug.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const debug = (
24
typeof process === 'object' &&
35
process.env &&

internal/identifiers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const numeric = /^[0-9]+$/
24
const compareIdentifiers = (a, b) => {
35
const anum = numeric.test(a)

internal/lrucache.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
class LRUCache {
24
constructor () {
35
this.max = 1000

internal/parse-options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// parse out just the options we care about
24
const looseOption = Object.freeze({ loose: true })
35
const emptyOpts = Object.freeze({ })

internal/re.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const {
24
MAX_SAFE_COMPONENT_LENGTH,
35
MAX_SAFE_BUILD_LENGTH,

map.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
'use strict'
2+
13
module.exports = testFile => testFile.replace(/test\//, '')

preload.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
'use strict'
2+
13
// XXX remove in v8 or beyond
24
module.exports = require('./index.js')

ranges/gtr.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// Determine if version is greater than all the versions possible in the range.
24
const outside = require('./outside')
35
const gtr = (version, range, options) => outside(version, range, '>', options)

ranges/intersects.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Range = require('../classes/range')
24
const intersects = (r1, r2, options) => {
35
r1 = new Range(r1, options)

ranges/ltr.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const outside = require('./outside')
24
// Determine if version is less than all the versions possible in the range
35
const ltr = (version, range, options) => outside(version, range, '<', options)

ranges/max-satisfying.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const Range = require('../classes/range')
35

ranges/min-satisfying.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const Range = require('../classes/range')
35
const minSatisfying = (versions, range, options) => {

ranges/min-version.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const Range = require('../classes/range')
35
const gt = require('../functions/gt')

ranges/outside.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const SemVer = require('../classes/semver')
24
const Comparator = require('../classes/comparator')
35
const { ANY } = Comparator

ranges/simplify.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// given a set of versions and a range, create a "simplified" range
24
// that includes the same versions that the original range does
35
// If the original range is shorter than the simplified one, return that.

ranges/subset.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Range = require('../classes/range.js')
24
const Comparator = require('../classes/comparator.js')
35
const { ANY } = Comparator

ranges/to-comparators.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Range = require('../classes/range')
24

35
// Mostly just for testing and legacy API reasons

ranges/valid.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const Range = require('../classes/range')
24
const validRange = (range, options) => {
35
try {

test/bin/semver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
23
const t = require('tap')
34

45
const thisVersion = require('../../package.json').version

test/classes/comparator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const { test } = require('tap')
24
const Comparator = require('../../classes/comparator')
35
const comparatorIntersection = require('../fixtures/comparator-intersection.js')

test/classes/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const t = require('tap')
24
t.same(require('../../classes'), {
35
SemVer: require('../../classes/semver'),

test/classes/range.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const { test } = require('tap')
24
const Range = require('../../classes/range')
35
const Comparator = require('../../classes/comparator')

test/classes/semver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const { test } = require('tap')
24
const SemVer = require('../../classes/semver')
35
const increments = require('../fixtures/increments.js')

test/fixtures/comparator-intersection.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// c0, c1, expected intersection, includePrerelease
24
module.exports = [
35
// One is a Version

test/fixtures/comparisons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// [version1, version2]
24
// version1 should be greater than version2
35
// used by the cmp, eq, gt, lt, and neq tests

test/fixtures/equality.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// [version1, version2]
24
// version1 should be equivalent to version2
35
module.exports = [

test/fixtures/increments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// [version, inc, result, options, identifier, identifierBase]
24
// inc(version, inc, options, identifier, identifierBase) -> result
35
module.exports = [

test/fixtures/invalid-versions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// none of these are semvers
24
// [value, reason, opt]
35
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../../internal/constants')

0 commit comments

Comments
 (0)