Skip to content

Commit

Permalink
Enable regex linting. Fix linting errors. yarn u. yarn docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Oct 27, 2023
1 parent 56f8a79 commit df569e6
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
14 changes: 10 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@ module.exports = {
env: {
node: true
},
plugins: [
"@typescript-eslint",
"eslint-plugin-import",
"eslint-plugin-node",
"regexp"
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:eslint-plugin-import/recommended",
"plugin:node/recommended"
"plugin:node/recommended",
"plugin:regexp/recommended"
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module"
},
plugins: ["@typescript-eslint", "eslint-plugin-import", "eslint-plugin-node"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/member-delimiter-style": [ "warn", { multiline: { delimiter: "none" } } ],
"@typescript-eslint/member-delimiter-style": ["warn", { multiline: { delimiter: "none" } }],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"eqeqeq": ["warn", "always", {"null": "ignore"}],
"eqeqeq": ["warn", "always", { "null": "ignore" }],
"import/no-cycle": "warn",
"import/no-unresolved": "off",
"import/named": "off",
Expand Down
4 changes: 2 additions & 2 deletions docs/classes/ExifToolTask.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5><span class="tsd-kind-parameter">err</span>: <span class="tsd-signature-type">string</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/photostructure/exiftool-vendored.js/blob/main/src/ExifToolTask.ts#L31">src/ExifToolTask.ts:31</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/photostructure/exiftool-vendored.js/blob/main/src/ExifToolTask.ts#L33">src/ExifToolTask.ts:33</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="onStart" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>on<wbr/>Start</span><a href="#onStart" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures tsd-is-inherited tsd-is-external">
Expand Down Expand Up @@ -249,7 +249,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <span class="tsd-signature-ty
<h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-parameter">error</span>: <span class="tsd-signature-type ">Error</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type tsd-kind-type-parameter">T</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/photostructure/exiftool-vendored.js/blob/main/src/ExifToolTask.ts#L29">src/ExifToolTask.ts:29</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/photostructure/exiftool-vendored.js/blob/main/src/ExifToolTask.ts#L31">src/ExifToolTask.ts:31</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="reject" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>reject</span><a href="#reject" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures tsd-is-inherited tsd-is-external">
Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,31 @@
]
},
"devDependencies": {
"@types/chai": "^4.3.7",
"@types/chai-as-promised": "^7.1.6",
"@types/chai-subset": "^1.3.3",
"@types/globule": "^1.1.7",
"@types/he": "^1.2.1",
"@types/mocha": "^10.0.2",
"@types/node": "^20.8.4",
"@types/progress": "^2.0.5",
"@types/tmp": "^0.2.4",
"@types/xmldom": "^0.1.32",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@types/chai": "^4.3.9",
"@types/chai-as-promised": "^7.1.7",
"@types/chai-subset": "^1.3.4",
"@types/globule": "^1.1.8",
"@types/he": "^1.2.2",
"@types/mocha": "^10.0.3",
"@types/node": "^20.8.9",
"@types/progress": "^2.0.6",
"@types/tmp": "^0.2.5",
"@types/xmldom": "^0.1.33",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@xmldom/xmldom": "^0.8.10",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"eslint": "^8.51.0",
"eslint-plugin-import": "^2.28.1",
"eslint": "^8.52.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-regexp": "^2.1.1",
"extract-zip": "^2.0.1",
"geo-tz": "^7.0.7",
"globule": "^1.3.4",
"mocha": "^10.2.0",
"npm-check-updates": "^16.14.5",
"npm-check-updates": "^16.14.6",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
Expand All @@ -106,7 +107,7 @@
"dependencies-note": "@types/luxon is a proper dependency, not devDependency, as our exported TypeScript typings reference luxon types. See <https://github.com/photostructure/exiftool-vendored.js/pull/108>",
"dependencies": {
"@photostructure/tz-lookup": "^8.0.0",
"@types/luxon": "^3.3.2",
"@types/luxon": "^3.3.3",
"batch-cluster": "^12.1.0",
"he": "^1.2.0",
"luxon": "^3.4.3"
Expand Down
2 changes: 1 addition & 1 deletion src/ExifTool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("ExifTool", function () {
// vendorVersion might have a ^ or ~ or something else as a prefix, so get
// rid of that:
return vendorVersion
.replace(/^[^.0-9]+/, "")
.replace(/^[^.\d]+/, "")
.split(".")
.slice(0, 2)
.map((ea) => leftPad(ea, 2, "0"))
Expand Down
4 changes: 3 additions & 1 deletion src/ExifToolTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export abstract class ExifToolTask<T> extends bc.Task<T> {
super(ExifToolTask.renderCommand(args), (stdout, stderr, passed) => {
let error: Maybe<Error>
if (notBlank(stderr) || !passed) {
const errMsg = (stderr ?? stdout).trim().replace(/error(:\s*|\b)/i, "")
const errMsg = (stderr ?? stdout)
.trim()
.replace(/error(?::\s*|\b)/i, "")
if (!this.isIgnorableError(errMsg)) {
this.errors.push(errMsg)
error = new Error(errMsg)
Expand Down
4 changes: 2 additions & 2 deletions src/Timezones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function normalizeZone(
}
let z = input
if (typeof z === "string") {
z = z.replace(/^(Zulu|Z|GMT)(\b|$)/, "UTC")
z = z.replace(/^(?:Zulu|Z|GMT)(?:\b|$)/, "UTC")
// Info.normalizeZone("") returns the system zone, which we never want.
// We also don't need to tease Info.normalizeZone with obviously
// non-offset inputs:
Expand Down Expand Up @@ -311,7 +311,7 @@ export function extractZone(
opts?.stripTZA !== false &&
// We only want to strip off the TZA if the input _doesn't_ end with "UTC"
// or "Z"
!/[.\d\s](UTC|Z)$/.test(str)
!/[.\d\s](?:UTC|Z)$/.test(str)
) {
str = str.replace(/\s[a-z]{2,5}$/i, "")
}
Expand Down
2 changes: 1 addition & 1 deletion src/VersionTask.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExifToolTask } from "./ExifToolTask"

export class VersionTask extends ExifToolTask<string> {
private static readonly versionRegex = /^\d{1,3}\.\d{1,3}(\.\d{1,3}})?$/
private static readonly versionRegex = /^\d{1,3}\.\d{1,3}(?:\.\d{1,3})?$/

constructor() {
super(["-ver"])
Expand Down
6 changes: 4 additions & 2 deletions src/update/mktags.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable regexp/optimal-quantifier-concatenation */
/* eslint-disable regexp/no-dupe-disjunctions */
require("source-map-support").install()

import { BatchCluster, Log, logger, setLogger } from "batch-cluster"
Expand Down Expand Up @@ -648,7 +650,7 @@ class TagMap {
}

const tagMap = new TagMap()
const saneTagRe = /^[a-z0-9_]+:[a-z0-9_]+$/i
const saneTagRe = /^\w+:\w+$/

const bar = new ProgressBar(
"reading tags [:bar] :current/:total files, :tasks pending @ :rate files/sec w/:procs procs :etas",
Expand Down Expand Up @@ -706,7 +708,7 @@ process.on("unhandledRejection", (reason: any) => {
})

function escapeKey(s: string): string {
return s.match(/[^0-9a-z_]/i) != null ? JSON.stringify(s) : s
return s.match(/\W/) != null ? JSON.stringify(s) : s
}

Promise.all(files.map((file) => readAndAddToTagMap(file)))
Expand Down

0 comments on commit df569e6

Please sign in to comment.