Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @343dev/eslint-config #20

Merged
merged 11 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_style = space

[*.yml]
indent_style = space
2 changes: 1 addition & 1 deletion .github/workflows/ci-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.17.0, 20.18.0, latest]
node-version: [18.18.0, 20.18.0, latest]
steps:
-
name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.17.0'
node-version: '18.18.0'
registry-url: 'https://registry.npmjs.org'
-
name: Check if package version has changed
Expand Down
292 changes: 145 additions & 147 deletions .optimiztrc.cjs
Original file line number Diff line number Diff line change
@@ -1,156 +1,154 @@
module.exports = {
optimize: {
jpeg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
lossy: {
quality: 80, // quality, integer 1-100
progressive: true, // use progressive (interlace) scan
chromaSubsampling: '4:2:0', // set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
optimizeCoding: true, // optimise Huffman coding tables
mozjpeg: false, // use mozjpeg defaults, equivalent to { trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }
trellisQuantisation: false, // apply trellis quantisation
overshootDeringing: false, // apply overshoot deringing
optimizeScans: false, // optimise progressive scans, forces progressive
quantizationTable: 0, // quantization table to use, integer 0-8
},
// https://github.com/google/guetzli
lossless: {
quality: 90, // visual quality to aim for, expressed as a JPEG quality value
memlimit: 6000, // memory limit in MB; guetzli will fail if unable to stay under the limit
nomemlimit: false, // do not limit memory usage
},
},
optimize: {
jpeg: {
// https://sharp.pixelplumbing.com/api-output#jpeg
lossy: {
quality: 80, // quality, integer 1-100
progressive: true, // use progressive (interlace) scan
chromaSubsampling: '4:2:0', // set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
optimizeCoding: true, // optimise Huffman coding tables
mozjpeg: false, // use mozjpeg defaults, equivalent to { trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }
trellisQuantisation: false, // apply trellis quantisation
overshootDeringing: false, // apply overshoot deringing
optimizeScans: false, // optimise progressive scans, forces progressive
quantizationTable: 0, // quantization table to use, integer 0-8
},
// https://github.com/google/guetzli
lossless: {
quality: 90, // visual quality to aim for, expressed as a JPEG quality value
memlimit: 6000, // memory limit in MB; guetzli will fail if unable to stay under the limit
nomemlimit: false, // do not limit memory usage
},
},

// https://sharp.pixelplumbing.com/api-output#png
png: {
lossy: {
progressive: false, // use progressive (interlace) scan
compressionLevel: 9, // zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
adaptiveFiltering: false, // use adaptive row filtering
palette: true, // quantise to a palette-based image with alpha transparency support
quality: 100, // use the lowest number of colours needed to achieve given quality, sets palette to true
effort: 7, // CPU effort, between 1 (fastest) and 10 (slowest), sets palette to true
colors: 256, // maximum number of palette entries, sets palette to true
dither: 1.0, // level of Floyd-Steinberg error diffusion, sets palette to true
},
lossless: {
progressive: false,
compressionLevel: 9,
adaptiveFiltering: true,
palette: false,
quality: 100,
effort: 7,
colors: 256,
dither: 1.0,
},
},
// https://sharp.pixelplumbing.com/api-output#png
png: {
lossy: {
progressive: false, // use progressive (interlace) scan
compressionLevel: 9, // zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
adaptiveFiltering: false, // use adaptive row filtering
palette: true, // quantise to a palette-based image with alpha transparency support
quality: 100, // use the lowest number of colours needed to achieve given quality, sets palette to true
effort: 7, // CPU effort, between 1 (fastest) and 10 (slowest), sets palette to true
colors: 256, // maximum number of palette entries, sets palette to true
dither: 1.0, // level of Floyd-Steinberg error diffusion, sets palette to true
},
lossless: {
progressive: false,
compressionLevel: 9,
adaptiveFiltering: true,
palette: false,
quality: 100,
effort: 7,
colors: 256,
dither: 1.0,
},
},

// http://www.lcdf.org/gifsicle/man.html
gif: {
lossy: {
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
careful: false, // write larger GIFs that avoid bugs in other programs
colors: 256, // reduce the number of distinct colors to num or less; must be between 2 and 256
lossy: 100, // alter image colors to shrink output file size at the cost of artifacts and noise
},
lossless: {
optimize: 0,
careful: true,
colors: 256,
lossy: 0,
},
},
// http://www.lcdf.org/gifsicle/man.html
gif: {
lossy: {
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
careful: false, // write larger GIFs that avoid bugs in other programs
colors: 256, // reduce the number of distinct colors to num or less; must be between 2 and 256
lossy: 100, // alter image colors to shrink output file size at the cost of artifacts and noise
},
lossless: {
optimize: 0,
careful: true,
colors: 256,
lossy: 0,
},
},

// https://github.com/svg/svgo#configuration
svg: {
multipass: true,
js2svg: {
pretty: true,
indent: 2,
},
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'cleanupListOfValues',
'convertStyleToAttrs',
'reusePaths',
],
},
},
// https://github.com/svg/svgo#configuration
svg: {
multipass: true,
js2svg: {
pretty: true,
indent: 2,
},
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'cleanupListOfValues',
'convertStyleToAttrs',
'reusePaths',
],
},
},

convert: {
// https://sharp.pixelplumbing.com/api-output#avif
avif: {
lossy: {
quality: 50, // quality, integer 1-100
lossless: false, // use lossless compression
effort: 4, // CPU effort, between 0 (fastest) and 9 (slowest)
chromaSubsampling: '4:4:4', // set to '4:2:0' to use chroma subsampling
bitdepth: 8, // set bitdepth to 8, 10 or 12 bit
},
lossless: {
quality: 50,
lossless: true,
effort: 4,
chromaSubsampling: '4:4:4',
bitdepth: 8, // set bitdepth to 8, 10 or 12 bit
},
},
convert: {
// https://sharp.pixelplumbing.com/api-output#avif
avif: {
lossy: {
quality: 50, // quality, integer 1-100
lossless: false, // use lossless compression
effort: 4, // CPU effort, between 0 (fastest) and 9 (slowest)
chromaSubsampling: '4:4:4', // set to '4:2:0' to use chroma subsampling
},
lossless: {
quality: 50,
lossless: true,
effort: 4,
chromaSubsampling: '4:4:4',
},
},

// https://sharp.pixelplumbing.com/api-output#webp
webp: {
lossy: {
quality: 85, // quality, integer 1-100
alphaQuality: 100, // quality of alpha layer, integer 0-100
lossless: false, // use lossless compression mode
nearLossless: false, // use near_lossless compression mode
smartSubsample: false, // use high quality chroma subsampling
// https://sharp.pixelplumbing.com/api-output#webp
webp: {
lossy: {
quality: 85, // quality, integer 1-100
alphaQuality: 100, // quality of alpha layer, integer 0-100
lossless: false, // use lossless compression mode
nearLossless: false, // use near_lossless compression mode
smartSubsample: false, // use high quality chroma subsampling
preset: 'default', // named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text
effort: 4, // CPU effort, between 0 (fastest) and 6 (slowest)
minSize: false, // prevent use of animation key frames to minimise file size (slow)
mixed: false, // allow mixture of lossy and lossless animation frames (slow)
},
lossless: {
quality: 85,
alphaQuality: 100,
lossless: true,
nearLossless: false,
smartSubsample: false,
effort: 4,
minSize: false,
mixed: false,
},
},
effort: 4, // CPU effort, between 0 (fastest) and 6 (slowest)
minSize: false, // prevent use of animation key frames to minimise file size (slow)
mixed: false, // allow mixture of lossy and lossless animation frames (slow)
},
lossless: {
quality: 85,
alphaQuality: 100,
lossless: true,
nearLossless: false,
smartSubsample: false,
effort: 4,
minSize: false,
mixed: false,
},
},

// https://developers.google.com/speed/webp/docs/gif2webp
webpGif: {
lossy: {
lossy: true, // encode image using lossy compression
mixed: false, // for each frame in the image, pick lossy or lossless compression heuristically
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
m: 6, // compression method (0=fast, 6=slowest)
min_size: true, // minimize output size; can be combined with -q, -m, -lossy or -mixed options
f: 0, // filter strength (0=off..100); for lossy encoding only
metadata: 'xmp', // comma separated list of metadata to copy from the input to the output if present; valid values: all, none, icc, xmp
loop_compatibility: false, // use compatibility mode for Chrome version prior to M62 (inclusive)
mt: true, // use multi-threading if available
},
lossless: {
lossy: false,
mixed: false,
q: 100,
m: false,
min_size: false,
metadata: 'xmp',
loop_compatibility: false,
mt: true,
},
},
},
// https://developers.google.com/speed/webp/docs/gif2webp
webpGif: {
lossy: {
lossy: true, // encode image using lossy compression
mixed: false, // for each frame in the image, pick lossy or lossless compression heuristically
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
m: 6, // compression method (0=fast, 6=slowest)
min_size: true, // minimize output size; can be combined with -q, -m, -lossy or -mixed options
f: 0, // filter strength (0=off..100); for lossy encoding only
metadata: 'xmp', // comma separated list of metadata to copy from the input to the output if present; valid values: all, none, icc, xmp
loop_compatibility: false, // use compatibility mode for Chrome version prior to M62 (inclusive)
mt: true, // use multi-threading if available
},
lossless: {
lossy: false,
mixed: false,
q: 100,
m: false,
min_size: false,
metadata: 'xmp',
loop_compatibility: false,
mt: true,
},
},
},
};
16 changes: 16 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import config from '@343dev/eslint-config';
import globals from 'globals';

export default [
...config,

{
ignores: ['.optimiztrc.cjs'],
},

{
languageOptions: {
globals: globals.jest,
},
},
];
2 changes: 1 addition & 1 deletion lib/find-config-file-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function findConfigFilePath(providedConfigPath) {

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

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

try {
Expand Down
7 changes: 4 additions & 3 deletions lib/show-total.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export function showTotal(before, after) {
const saved = formatBytes(before - after);

logEmptyLine();
log(ratio > 0
? `Yay! You saved ${saved} (${ratio}%)`
: 'Done!',
log(
ratio > 0
? `Yay! You saved ${saved} (${ratio}%)`
: 'Done!',
);
}
Loading