Skip to content

Commit a739750

Browse files
authored
Merge pull request #20 from 343dev/improvement/eslint
Update @343dev/eslint-config
2 parents 8730f50 + 2cf7ead commit a739750

File tree

9 files changed

+819
-735
lines changed

9 files changed

+819
-735
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ insert_final_newline = true
1111

1212
[*.md]
1313
trim_trailing_whitespace = false
14+
indent_style = space
1415

1516
[*.yml]
1617
indent_style = space

.github/workflows/ci-nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: [18.17.0, 20.18.0, latest]
14+
node-version: [18.18.0, 20.18.0, latest]
1515
steps:
1616
-
1717
name: Checkout repository

.github/workflows/publish-npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Setup Node.js
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: '18.17.0'
24+
node-version: '18.18.0'
2525
registry-url: 'https://registry.npmjs.org'
2626
-
2727
name: Check if package version has changed

.optimiztrc.cjs

Lines changed: 145 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,154 @@
11
module.exports = {
2-
optimize: {
3-
jpeg: {
4-
// https://sharp.pixelplumbing.com/api-output#jpeg
5-
lossy: {
6-
quality: 80, // quality, integer 1-100
7-
progressive: true, // use progressive (interlace) scan
8-
chromaSubsampling: '4:2:0', // set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
9-
optimizeCoding: true, // optimise Huffman coding tables
10-
mozjpeg: false, // use mozjpeg defaults, equivalent to { trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }
11-
trellisQuantisation: false, // apply trellis quantisation
12-
overshootDeringing: false, // apply overshoot deringing
13-
optimizeScans: false, // optimise progressive scans, forces progressive
14-
quantizationTable: 0, // quantization table to use, integer 0-8
15-
},
16-
// https://github.com/google/guetzli
17-
lossless: {
18-
quality: 90, // visual quality to aim for, expressed as a JPEG quality value
19-
memlimit: 6000, // memory limit in MB; guetzli will fail if unable to stay under the limit
20-
nomemlimit: false, // do not limit memory usage
21-
},
22-
},
2+
optimize: {
3+
jpeg: {
4+
// https://sharp.pixelplumbing.com/api-output#jpeg
5+
lossy: {
6+
quality: 80, // quality, integer 1-100
7+
progressive: true, // use progressive (interlace) scan
8+
chromaSubsampling: '4:2:0', // set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
9+
optimizeCoding: true, // optimise Huffman coding tables
10+
mozjpeg: false, // use mozjpeg defaults, equivalent to { trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }
11+
trellisQuantisation: false, // apply trellis quantisation
12+
overshootDeringing: false, // apply overshoot deringing
13+
optimizeScans: false, // optimise progressive scans, forces progressive
14+
quantizationTable: 0, // quantization table to use, integer 0-8
15+
},
16+
// https://github.com/google/guetzli
17+
lossless: {
18+
quality: 90, // visual quality to aim for, expressed as a JPEG quality value
19+
memlimit: 6000, // memory limit in MB; guetzli will fail if unable to stay under the limit
20+
nomemlimit: false, // do not limit memory usage
21+
},
22+
},
2323

24-
// https://sharp.pixelplumbing.com/api-output#png
25-
png: {
26-
lossy: {
27-
progressive: false, // use progressive (interlace) scan
28-
compressionLevel: 9, // zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
29-
adaptiveFiltering: false, // use adaptive row filtering
30-
palette: true, // quantise to a palette-based image with alpha transparency support
31-
quality: 100, // use the lowest number of colours needed to achieve given quality, sets palette to true
32-
effort: 7, // CPU effort, between 1 (fastest) and 10 (slowest), sets palette to true
33-
colors: 256, // maximum number of palette entries, sets palette to true
34-
dither: 1.0, // level of Floyd-Steinberg error diffusion, sets palette to true
35-
},
36-
lossless: {
37-
progressive: false,
38-
compressionLevel: 9,
39-
adaptiveFiltering: true,
40-
palette: false,
41-
quality: 100,
42-
effort: 7,
43-
colors: 256,
44-
dither: 1.0,
45-
},
46-
},
24+
// https://sharp.pixelplumbing.com/api-output#png
25+
png: {
26+
lossy: {
27+
progressive: false, // use progressive (interlace) scan
28+
compressionLevel: 9, // zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
29+
adaptiveFiltering: false, // use adaptive row filtering
30+
palette: true, // quantise to a palette-based image with alpha transparency support
31+
quality: 100, // use the lowest number of colours needed to achieve given quality, sets palette to true
32+
effort: 7, // CPU effort, between 1 (fastest) and 10 (slowest), sets palette to true
33+
colors: 256, // maximum number of palette entries, sets palette to true
34+
dither: 1.0, // level of Floyd-Steinberg error diffusion, sets palette to true
35+
},
36+
lossless: {
37+
progressive: false,
38+
compressionLevel: 9,
39+
adaptiveFiltering: true,
40+
palette: false,
41+
quality: 100,
42+
effort: 7,
43+
colors: 256,
44+
dither: 1.0,
45+
},
46+
},
4747

48-
// http://www.lcdf.org/gifsicle/man.html
49-
gif: {
50-
lossy: {
51-
optimize: 3, // attempt to shrink the file sizes of GIF animations; higher levels take longer, but may have better results; there are currently three levels
52-
careful: false, // write larger GIFs that avoid bugs in other programs
53-
colors: 256, // reduce the number of distinct colors to num or less; must be between 2 and 256
54-
lossy: 100, // alter image colors to shrink output file size at the cost of artifacts and noise
55-
},
56-
lossless: {
57-
optimize: 0,
58-
careful: true,
59-
colors: 256,
60-
lossy: 0,
61-
},
62-
},
48+
// http://www.lcdf.org/gifsicle/man.html
49+
gif: {
50+
lossy: {
51+
optimize: 3, // attempt to shrink the file sizes of GIF animations; higher levels take longer, but may have better results; there are currently three levels
52+
careful: false, // write larger GIFs that avoid bugs in other programs
53+
colors: 256, // reduce the number of distinct colors to num or less; must be between 2 and 256
54+
lossy: 100, // alter image colors to shrink output file size at the cost of artifacts and noise
55+
},
56+
lossless: {
57+
optimize: 0,
58+
careful: true,
59+
colors: 256,
60+
lossy: 0,
61+
},
62+
},
6363

64-
// https://github.com/svg/svgo#configuration
65-
svg: {
66-
multipass: true,
67-
js2svg: {
68-
pretty: true,
69-
indent: 2,
70-
},
71-
plugins: [
72-
{
73-
name: 'preset-default',
74-
params: {
75-
overrides: {
76-
removeViewBox: false,
77-
},
78-
},
79-
},
80-
'cleanupListOfValues',
81-
'convertStyleToAttrs',
82-
'reusePaths',
83-
],
84-
},
85-
},
64+
// https://github.com/svg/svgo#configuration
65+
svg: {
66+
multipass: true,
67+
js2svg: {
68+
pretty: true,
69+
indent: 2,
70+
},
71+
plugins: [
72+
{
73+
name: 'preset-default',
74+
params: {
75+
overrides: {
76+
removeViewBox: false,
77+
},
78+
},
79+
},
80+
'cleanupListOfValues',
81+
'convertStyleToAttrs',
82+
'reusePaths',
83+
],
84+
},
85+
},
8686

87-
convert: {
88-
// https://sharp.pixelplumbing.com/api-output#avif
89-
avif: {
90-
lossy: {
91-
quality: 50, // quality, integer 1-100
92-
lossless: false, // use lossless compression
93-
effort: 4, // CPU effort, between 0 (fastest) and 9 (slowest)
94-
chromaSubsampling: '4:4:4', // set to '4:2:0' to use chroma subsampling
95-
bitdepth: 8, // set bitdepth to 8, 10 or 12 bit
96-
},
97-
lossless: {
98-
quality: 50,
99-
lossless: true,
100-
effort: 4,
101-
chromaSubsampling: '4:4:4',
102-
bitdepth: 8, // set bitdepth to 8, 10 or 12 bit
103-
},
104-
},
87+
convert: {
88+
// https://sharp.pixelplumbing.com/api-output#avif
89+
avif: {
90+
lossy: {
91+
quality: 50, // quality, integer 1-100
92+
lossless: false, // use lossless compression
93+
effort: 4, // CPU effort, between 0 (fastest) and 9 (slowest)
94+
chromaSubsampling: '4:4:4', // set to '4:2:0' to use chroma subsampling
95+
},
96+
lossless: {
97+
quality: 50,
98+
lossless: true,
99+
effort: 4,
100+
chromaSubsampling: '4:4:4',
101+
},
102+
},
105103

106-
// https://sharp.pixelplumbing.com/api-output#webp
107-
webp: {
108-
lossy: {
109-
quality: 85, // quality, integer 1-100
110-
alphaQuality: 100, // quality of alpha layer, integer 0-100
111-
lossless: false, // use lossless compression mode
112-
nearLossless: false, // use near_lossless compression mode
113-
smartSubsample: false, // use high quality chroma subsampling
104+
// https://sharp.pixelplumbing.com/api-output#webp
105+
webp: {
106+
lossy: {
107+
quality: 85, // quality, integer 1-100
108+
alphaQuality: 100, // quality of alpha layer, integer 0-100
109+
lossless: false, // use lossless compression mode
110+
nearLossless: false, // use near_lossless compression mode
111+
smartSubsample: false, // use high quality chroma subsampling
114112
preset: 'default', // named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text
115-
effort: 4, // CPU effort, between 0 (fastest) and 6 (slowest)
116-
minSize: false, // prevent use of animation key frames to minimise file size (slow)
117-
mixed: false, // allow mixture of lossy and lossless animation frames (slow)
118-
},
119-
lossless: {
120-
quality: 85,
121-
alphaQuality: 100,
122-
lossless: true,
123-
nearLossless: false,
124-
smartSubsample: false,
125-
effort: 4,
126-
minSize: false,
127-
mixed: false,
128-
},
129-
},
113+
effort: 4, // CPU effort, between 0 (fastest) and 6 (slowest)
114+
minSize: false, // prevent use of animation key frames to minimise file size (slow)
115+
mixed: false, // allow mixture of lossy and lossless animation frames (slow)
116+
},
117+
lossless: {
118+
quality: 85,
119+
alphaQuality: 100,
120+
lossless: true,
121+
nearLossless: false,
122+
smartSubsample: false,
123+
effort: 4,
124+
minSize: false,
125+
mixed: false,
126+
},
127+
},
130128

131-
// https://developers.google.com/speed/webp/docs/gif2webp
132-
webpGif: {
133-
lossy: {
134-
lossy: true, // encode image using lossy compression
135-
mixed: false, // for each frame in the image, pick lossy or lossless compression heuristically
136-
q: 75, // in case of lossy compression, a small factor produces a smaller file with lower quality; best quality is achieved by using a value of 100
137-
m: 6, // compression method (0=fast, 6=slowest)
138-
min_size: true, // minimize output size; can be combined with -q, -m, -lossy or -mixed options
139-
f: 0, // filter strength (0=off..100); for lossy encoding only
140-
metadata: 'xmp', // comma separated list of metadata to copy from the input to the output if present; valid values: all, none, icc, xmp
141-
loop_compatibility: false, // use compatibility mode for Chrome version prior to M62 (inclusive)
142-
mt: true, // use multi-threading if available
143-
},
144-
lossless: {
145-
lossy: false,
146-
mixed: false,
147-
q: 100,
148-
m: false,
149-
min_size: false,
150-
metadata: 'xmp',
151-
loop_compatibility: false,
152-
mt: true,
153-
},
154-
},
155-
},
129+
// https://developers.google.com/speed/webp/docs/gif2webp
130+
webpGif: {
131+
lossy: {
132+
lossy: true, // encode image using lossy compression
133+
mixed: false, // for each frame in the image, pick lossy or lossless compression heuristically
134+
q: 75, // in case of lossy compression, a small factor produces a smaller file with lower quality; best quality is achieved by using a value of 100
135+
m: 6, // compression method (0=fast, 6=slowest)
136+
min_size: true, // minimize output size; can be combined with -q, -m, -lossy or -mixed options
137+
f: 0, // filter strength (0=off..100); for lossy encoding only
138+
metadata: 'xmp', // comma separated list of metadata to copy from the input to the output if present; valid values: all, none, icc, xmp
139+
loop_compatibility: false, // use compatibility mode for Chrome version prior to M62 (inclusive)
140+
mt: true, // use multi-threading if available
141+
},
142+
lossless: {
143+
lossy: false,
144+
mixed: false,
145+
q: 100,
146+
m: false,
147+
min_size: false,
148+
metadata: 'xmp',
149+
loop_compatibility: false,
150+
mt: true,
151+
},
152+
},
153+
},
156154
};

eslint.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import config from '@343dev/eslint-config';
2+
import globals from 'globals';
3+
4+
export default [
5+
...config,
6+
7+
{
8+
ignores: ['.optimiztrc.cjs'],
9+
},
10+
11+
{
12+
languageOptions: {
13+
globals: globals.jest,
14+
},
15+
},
16+
];

lib/find-config-file-path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function findConfigFilePath(providedConfigPath) {
2727

2828
let currentDirectoryPath = path.resolve(process.cwd());
2929

30-
while (true) { // eslint-disable-line no-constant-condition
30+
while (true) {
3131
const currentConfigPath = path.join(currentDirectoryPath, DEFAULT_CONFIG_FILENAME);
3232

3333
try {

lib/show-total.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export function showTotal(before, after) {
77
const saved = formatBytes(before - after);
88

99
logEmptyLine();
10-
log(ratio > 0
11-
? `Yay! You saved ${saved} (${ratio}%)`
12-
: 'Done!',
10+
log(
11+
ratio > 0
12+
? `Yay! You saved ${saved} (${ratio}%)`
13+
: 'Done!',
1314
);
1415
}

0 commit comments

Comments
 (0)