Skip to content

Commit

Permalink
chore(lint): resolve Options class to default export
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWook committed Jan 17, 2024
1 parent 04ec72b commit 02824b7
Show file tree
Hide file tree
Showing 45 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion data-scripts/_generators/PasswordGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sprintfClass from 'sprintf-js'
import { MatchExtended } from '@zxcvbn-ts/core/src/types'
import Matching from '../../packages/libraries/main/src/Matching'
import estimateGuesses from '../../packages/libraries/main/src/scoring/estimate'
import { Options } from '../../packages/libraries/main/src/Options'
import Options from '../../packages/libraries/main/src/Options'

const CUTOFF = 10
const BATCH_SIZE = 1000000
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/Feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from './Options'
import Options from './Options'
import { DefaultFeedbackFunction, FeedbackType, MatchEstimated } from './types'
import bruteforceMatcher from './matcher/bruteforce/feedback'
import dateMatcher from './matcher/date/feedback'
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/Matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import repeatMatcher from './matcher/repeat/matching'
import sequenceMatcher from './matcher/sequence/matching'
import spatialMatcher from './matcher/spatial/matching'
import separatorMatcher from './matcher/separator/matching'
import { Options } from './Options'
import Options from './Options'

/*
* -------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import translationKeys from './data/translationKeys'
import TrieNode from './matcher/dictionary/variants/matching/unmunger/TrieNode'
import l33tTableToTrieNode from './matcher/dictionary/variants/matching/unmunger/l33tTableToTrieNode'

export class Options {
export default class Options {
public matchers: Matchers = {}

public l33tTable: OptionsL33tTable = l33tTable
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/TimeEstimates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from './Options'
import Options from './Options'
import { CrackTimesDisplay, CrackTimesSeconds, Score } from './types'

const SECOND = 1
Expand Down
4 changes: 2 additions & 2 deletions packages/libraries/main/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Matching from './Matching'
import TimeEstimates from './TimeEstimates'
import Feedback from './Feedback'
import { Options } from './Options'
import Options from './Options'
import debounce from './utils/debounce'
import {
Matcher,
Expand Down Expand Up @@ -88,4 +88,4 @@ class ZxcvbnFactory {
}

export * from './types'
export { ZxcvbnFactory, Options, debounce }
export { ZxcvbnFactory, debounce }
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/date/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'

export default (options: Options) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/date/matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../data/const'
import { sorted } from '../../utils/helper'
import { DateMatch, MatchOptions } from '../../types'
import { Options } from '../../Options'
import Options from '../../Options'

type DateMatchOptions = Pick<MatchOptions, 'password'>

Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/dictionary/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'
import { MatchEstimated } from '../../types'
import { ALL_UPPER_INVERTED, START_UPPER } from '../../data/const'

Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/dictionary/matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import findLevenshteinDistance, {
FindLevenshteinDistanceResult,
} from '../../utils/levenshtein'
import { sorted } from '../../utils/helper'
import { Options } from '../../Options'
import Options from '../../Options'
import { DictionaryNames, DictionaryMatch, L33tMatch } from '../../types'
import Reverse from './variants/matching/reverse'
import L33t from './variants/matching/l33t'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../../../Options'
import Options from '../../../../Options'
import { DictionaryMatch, L33tMatch } from '../../../../types'
import { DefaultMatch, DictionaryMatchOptions } from '../../types'
import getCleanPasswords, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DictionaryMatch } from '../../../../types'
import { DefaultMatch, DictionaryMatchOptions } from '../../types'
import { Options } from '../../../../Options'
import Options from '../../../../Options'

/*
* -------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class CleanPasswords {

if (index === this.substr.length) {
if (onlyFullSub === isFullSub) {
this.finalPasswords.push({ password: this.buffer.join(''), changes, isFullSubstitution: onlyFullSub })
this.finalPasswords.push({
password: this.buffer.join(''),
changes,
isFullSubstitution: onlyFullSub,
})
}
return
}
Expand All @@ -93,10 +97,7 @@ class CleanPasswords {
// Skip if this would be a 4th or more consecutive substitution of the same letter
// this should work in all language as there shouldn't be the same letter more than four times in a row
// So we can ignore the rest to save calculation time
if (
lastSubLetter === sub &&
consecutiveSubCount >= 3
) {
if (lastSubLetter === sub && consecutiveSubCount >= 3) {
// eslint-disable-next-line no-continue
continue
}
Expand All @@ -120,9 +121,7 @@ class CleanPasswords {
changes: newSubs,
lastSubLetter: sub,
consecutiveSubCount:
lastSubLetter === sub
? consecutiveSubCount + 1
: 1,
lastSubLetter === sub ? consecutiveSubCount + 1 : 1,
})
// backtrack by ignoring the added postfix
this.buffer.pop()
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/regex/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'
import { MatchEstimated } from '../../types'

export default (options: Options, match: MatchEstimated) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/regex/matching.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { REGEXEN } from '../../data/const'
import { sorted } from '../../utils/helper'
import { MatchOptions, RegexMatch } from '../../types'
import { Options } from '../../Options'
import Options from '../../Options'

type RegexMatchOptions = Pick<MatchOptions, 'password'>

Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/repeat/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'
import { MatchEstimated } from '../../types'

export default (options: Options, match: MatchEstimated) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/repeat/matching.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MatchOptions, RepeatMatch } from '../../types'
import Scoring from '../../scoring'
import Matching from '../../Matching'
import { Options } from '../../Options'
import Options from '../../Options'

/*
*-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/separator/matching.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SEPERATOR_CHARS } from '../../data/const'
import { MatchOptions, SeparatorMatch } from '../../types'
import { Options } from '../../Options'
import Options from '../../Options'

type SeparatorMatchOptions = Pick<MatchOptions, 'password'>

Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/sequence/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'

export default (options: Options) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/sequence/matching.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ALL_UPPER, ALL_LOWER, ALL_DIGIT } from '../../data/const'
import { MatchOptions, SequenceMatch } from '../../types'
import { Options } from '../../Options'
import Options from '../../Options'

type UpdateParams = {
i: number
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/spatial/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../Options'
import Options from '../../Options'
import { MatchEstimated } from '../../types'

export default (options: Options, match: MatchEstimated) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/spatial/matching.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sorted, extend } from '../../utils/helper'
import { Options } from '../../Options'
import Options from '../../Options'
import { LooseObject, MatchOptions, SpatialMatch } from '../../types'

type SpatialMatchOptions = Pick<MatchOptions, 'password'>
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/matcher/spatial/scoring.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import utils from '../../scoring/utils'
import { Options } from '../../Options'
import Options from '../../Options'
import {
LooseObject,
MatchEstimated,
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/scoring/estimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
MIN_SUBMATCH_GUESSES_MULTI_CHAR,
} from '../data/const'
import utils from './utils'
import { Options } from '../Options'
import Options from '../Options'
import {
DefaultScoringFunction,
LooseObject,
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/scoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MatchEstimated,
LooseObject,
} from '../types'
import { Options } from '../Options'
import Options from '../Options'

const scoringHelper = {
password: '',
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { REGEXEN } from './data/const'
import { DictionaryReturn } from './matcher/dictionary/scoring'
import Matching from './Matching'
import { PasswordChanges } from './matcher/dictionary/variants/matching/unmunger/getCleanPasswords'
import { Options } from './Options'
import Options from './Options'

export type TranslationKeys = typeof translationKeys
export type L33tTableDefault = typeof l33tTableDefault
Expand Down
3 changes: 2 additions & 1 deletion packages/libraries/main/test/customMatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as zxcvbnCommonPackage from '../../../languages/common/src'
import * as zxcvbnEnPackage from '../../../languages/en/src'
import { Options, ZxcvbnFactory } from '../src'
import { ZxcvbnFactory } from '../src'
import { Match, Matcher } from '../src/types'
import { sorted } from '../src/utils/helper'
import Options from '../src/Options'

const minLengthMatcher: Matcher = {
Matching: class MatchMinLength {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/feedback.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import translations from '../../../languages/en/src/translations'
import { Options } from '../src/Options'
import Options from '../src/Options'
import Feedback from '../src/Feedback'

const zxcvbnOptions = new Options({
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/matcher/date/matching.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MatchDate from '../../../src/matcher/date/matching'
import checkMatches from '../../helper/checkMatches'
import genpws from '../../helper/genpws'
import { Options } from '../../../src'
import Options from '../../../src/Options'

describe('date matching', () => {
const zxcvbnOptions = new Options()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as zxcvbnEnPackage from '../../../../../languages/en/src'
import MatchDictionary from '../../../src/matcher/dictionary/matching'
import checkMatches from '../../helper/checkMatches'
import genpws from '../../helper/genpws'
import { Options } from '../../../src/Options'
import Options from '../../../src/Options'

describe('dictionary matching', () => {
describe('Default dictionary', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MatchDictionaryReverse from '../../../../../src/matcher/dictionary/variants/matching/reverse'
import MatchDictionary from '../../../../../src/matcher/dictionary/matching'
import checkMatches from '../../../../helper/checkMatches'
import { Options } from '../../../../../src/Options'
import Options from '../../../../../src/Options'

describe('dictionary reverse matching', () => {
const testDicts = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MatchL33t from '../../../../../src/matcher/dictionary/variants/matching/l33t'
import MatchDictionary from '../../../../../src/matcher/dictionary/matching'
import checkMatches from '../../../../helper/checkMatches'
import { Options } from '../../../../../src/Options'
import Options from '../../../../../src/Options'
import { sorted } from '../../../../../src/utils/helper'

describe('l33t matching', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MatchRegex from '../../../src/matcher/regex/matching'
import checkMatches from '../../helper/checkMatches'
import { Options } from '../../../src'
import Options from '../../../src/Options'

describe('regex matching', () => {
const data = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import MatchRepeat from '../../../src/matcher/repeat/matching'
import checkMatches from '../../helper/checkMatches'
import genpws from '../../helper/genpws'
import MatchOmni from '../../../src/Matching'
import { Options } from '../../../src/Options'
import Options from '../../../src/Options'
import { RepeatMatch } from '../../../src/types'

const zxcvbnOptions = new Options()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import repeatGuesses from '../../../src/matcher/repeat/scoring'
import Scoring from '../../../src/scoring'
import MatchOmni from '../../../src/Matching'
import { Options } from '../../../src/Options'
import Options from '../../../src/Options'
import { MatchExtended } from '../../../src/types'

const zxcvbnOptions = new Options()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MatchSeparator from '../../../src/matcher/separator/matching'
import checkMatches from '../../helper/checkMatches'
import { Options } from '../../../src'
import Options from '../../../src/Options'

describe('separator matching', () => {
const zxcvbnOptions = new Options()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MatchSequence from '../../../src/matcher/sequence/matching'
import checkMatches from '../../helper/checkMatches'
import genpws from '../../helper/genpws'
import { Options } from '../../../src'
import Options from '../../../src/Options'

describe('sequence matching', () => {
const zxcvbnOptions = new Options()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MatchSpatial from '../../../src/matcher/spatial/matching'
import checkMatches from '../../helper/checkMatches'
import * as zxcvbnCommonPackage from '../../../../../languages/common/src'
import { Options } from '../../../src/Options'
import Options from '../../../src/Options'
import { LooseObject } from '../../../src/types'

const { adjacencyGraphs } = zxcvbnCommonPackage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as zxcvbnCommonPackage from '../../../../../languages/common/src'
import spatialGuesses from '../../../src/matcher/spatial/scoring'
import { Options } from '../../../src/Options'
import Options from '../../../src/Options'

describe('scoring: guesses spatial', () => {
const zxcvbnOptions = new Options({
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/matching.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as zxcvbnCommonPackage from '../../../languages/common/src'
import * as zxcvbnEnPackage from '../../../languages/en/src'
import MatchOmni from '../src/Matching'
import { Options } from '../src/Options'
import Options from '../src/Options'
import { MatchExtended } from '../src/types'

const zxcvbnOptions = new Options({
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../src/Options'
import Options from '../src/Options'
import translationKeys from '../src/data/translationKeys'

describe('Options', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/scoring/guesses/calc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import estimate from '../../../src/scoring/estimate'
import dateGuesses from '../../../src/matcher/date/scoring'
import { Options } from '../../../src'
import Options from '../../../src/Options'

describe('scoring', () => {
const zxcvbnOptions = new Options()
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/scoring/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Scoring from '../../src/scoring'
import { Options } from '../../src/Options'
import Options from '../../src/Options'

describe('scoring search', () => {
const zxcvbnOptions = new Options()
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/test/timeEstimates.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import translations from '../../../languages/en/src/translations'
import TimeEstimates from '../src/TimeEstimates'
import { Options } from '../src/Options'
import Options from '../src/Options'

const zxcvbnOptions = new Options({
translations,
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/pwned/test/matching.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { matcherPwnedFactory } from '../src'
import { Options } from '../../main/src'
import Options from '../../main/src/Options'

const fetch = jest.fn(async () => ({
text() {
Expand Down

0 comments on commit 02824b7

Please sign in to comment.