Skip to content

Commit 5bc0120

Browse files
committed
linting improvements
1 parent 087d506 commit 5bc0120

22 files changed

+40
-24
lines changed

.eslintrc

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
"max-statements": ["error", 23],
2121
"@typescript-eslint/explicit-function-return-type": "off",
2222
"@typescript-eslint/interface-name-prefix": "off",
23-
"@typescript-eslint/member-delimiter-style": ["error", {
24-
"multiline": { "delimiter": "none" }
25-
}],
23+
"@typescript-eslint/member-delimiter-style": [
24+
"error",
25+
{
26+
"multiline": { "delimiter": "none" }
27+
}
28+
],
2629
"@typescript-eslint/no-unused-vars": "error",
2730
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
31+
"@typescript-eslint/consistent-type-imports": "error"
2832
},
2933
"overrides": [
3034
{

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll": true,
5+
"source.fixAll.eslint": true
6+
},
7+
"[typescript]": {
8+
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
9+
}
10+
}

lib/detector.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { typeHandlers, imageType } from './types/index'
1+
import type { imageType } from './types/index'
2+
import { typeHandlers } from './types/index'
23

34
const keys = Object.keys(typeHandlers) as imageType[]
45

lib/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
33
import Queue from 'queue'
4-
import { typeHandlers, imageType } from './types/index'
4+
import type { imageType } from './types/index'
5+
import { typeHandlers } from './types/index'
56
import { detector } from './detector'
6-
import { ISizeCalculationResult } from './types/interface'
7+
import type { ISizeCalculationResult } from './types/interface'
78

89
type CallbackFn = (e: Error | null, r?: ISizeCalculationResult) => void
910

lib/types/bmp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toUTF8String, readInt32LE, readUInt32LE } from './utils'
33

44
export const BMP: IImage = {

lib/types/cur.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { ICO } from './ico'
33
import { readUInt16LE } from './utils'
44

lib/types/dds.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { readUInt32LE } from './utils'
33

44
export const DDS: IImage = {

lib/types/gif.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toUTF8String, readUInt16LE } from './utils'
33

44
const gifRegexp = /^GIF8[79]a/

lib/types/icns.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage, ISize } from './interface'
1+
import type { IImage, ISize } from './interface'
22
import { toUTF8String, readUInt32BE } from './utils'
33

44
/**

lib/types/ico.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage, ISize } from './interface'
1+
import type { IImage, ISize } from './interface'
22
import { readUInt16LE } from './utils'
33

44
const TYPE_ICON = 1

lib/types/j2c.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toHexString, readUInt32BE } from './utils'
33

44
export const J2C: IImage = {

lib/types/jp2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage, ISize } from './interface'
1+
import type { IImage, ISize } from './interface'
22
import { toHexString, toUTF8String, readUInt32BE, readUInt16BE } from './utils'
33

44
const BoxTypes = {

lib/types/jpg.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// with a maximum size of 4096 bytes. so if the SOF marker is outside
44
// if this range we can't detect the file size correctly.
55

6-
import { IImage, ISize } from './interface'
6+
import type { IImage, ISize } from './interface'
77
import { readUInt, readUInt16BE, toHexString } from './utils'
88

99
const EXIF_MARKER = '45786966'

lib/types/ktx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toUTF8String, readUInt32LE } from './utils'
33

44
export const KTX: IImage = {

lib/types/png.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toUTF8String, readUInt32BE } from './utils'
33

44
const pngSignature = 'PNG\r\n\x1a\n'

lib/types/pnm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage, ISize } from './interface'
1+
import type { IImage, ISize } from './interface'
22
import { toUTF8String } from './utils'
33

44
const PNMTypes = {

lib/types/psd.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { toUTF8String, readUInt32BE } from './utils'
33

44
export const PSD: IImage = {

lib/types/svg.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage, ISize } from './interface'
1+
import type { IImage, ISize } from './interface'
22
import { toUTF8String } from './utils'
33

44
type IAttributes = {

lib/types/tga.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IImage } from './interface'
1+
import type { IImage } from './interface'
22
import { readUInt16LE } from './utils'
33

44
export const TGA: IImage = {

lib/types/tiff.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// based on http://www.compix.com/fileformattif.htm
22
// TO-DO: support big-endian as well
33
import * as fs from 'fs'
4-
import { IImage } from './interface'
4+
import type { IImage } from './interface'
55
import { readUInt, toHexString, toUTF8String } from './utils'
66

77
// Read IFD (image-file-directory) into a buffer

lib/types/webp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// based on https://developers.google.com/speed/webp/docs/riff_container
2-
import { IImage, ISize } from './interface'
2+
import type { IImage, ISize } from './interface'
33
import { toHexString, toUTF8String, readInt16LE, readUInt24LE } from './utils'
44

55
function calculateExtended(input: Uint8Array): ISize {

specs/valid.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { extname, resolve } from 'path'
44
import { openSync, readSync } from 'fs'
55
import { imageSize } from '../lib'
66
import { detector } from '../lib/detector'
7-
import { ISizeCalculationResult } from '../lib/types/interface'
7+
import type { ISizeCalculationResult } from '../lib/types/interface'
88

99
const bufferSize = 8192
1010

0 commit comments

Comments
 (0)