Skip to content

Commit

Permalink
optimize biome config
Browse files Browse the repository at this point in the history
  • Loading branch information
yoriiis committed Nov 18, 2024
1 parent ef90d77 commit 01bbb29
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 161 deletions.
149 changes: 7 additions & 142 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,91 +20,10 @@
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noBannedTypes": "error",
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noUselessLoneBlockStatements": "error",
"noUselessRename": "error",
"noUselessTernary": "error",
"noUselessTypeConstraint": "error",
"noUselessUndefinedInitialization": "error",
"noVoid": "error",
"noWith": "error",
"useLiteralKeys": "error",
"useRegexLiterals": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInvalidConstructorSuper": "error",
"noInvalidUseBeforeDeclaration": "error",
"noNewSymbol": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnusedVariables": "warn",
"useArrayLiterals": "error",
"useIsNan": "error"
},
"security": { "noGlobalEval": "error" },
"style": {
"noCommaOperator": "error",
"noInferrableTypes": "error",
"noNamespace": "error",
"noNonNullAssertion": "warn",
"noVar": "warn",
"noYodaExpression": "error",
"useAsConstAssertion": "error",
"useBlockStatements": "error",
"useConsistentBuiltinInstantiation": "error",
"useConst": "error",
"useSingleVarDeclarator": "error"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noConsole": "off",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDoubleEquals": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noExplicitAny": "off",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noMisleadingInstantiator": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useDefaultSwitchClauseLast": "error",
"useNamespaceKeyword": "error",
"useValidTypeof": "error"
}
},
"ignore": []
"recommended": true,
"complexity": { "noForEach": "off" },
"suspicious": { "noExplicitAny": "off" }
}
},
"javascript": {
"formatter": {
Expand All @@ -113,64 +32,10 @@
"trailingCommas": "none",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSameLine": true,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
},
"globals": [
"document",
"window",
"navigator",
"beforeEach",
"jest",
"expect",
"it",
"afterEach",
"describe"
]
},
"overrides": [
{
"include": ["*.ts", "*.tsx", "*.mts", "*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off",
"useValidTypeof": "off"
}
}
}
},
{
"include": ["*.md"],
"javascript": {
"formatter": { "semicolons": "always", "quoteStyle": "single" }
},
"formatter": { "indentStyle": "space", "indentWidth": 2 }
},
{ "include": ["*.html"], "formatter": { "lineWidth": 320 } }
]
}
}
}
2 changes: 1 addition & 1 deletion example/svgo.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crypto from 'crypto';
import crypto from 'node:crypto';

export default {
multipass: true,
Expand Down
4 changes: 2 additions & 2 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { fileURLToPath } from 'url';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import TerserJSPlugin from 'terser-webpack-plugin';
import SvgChunkWebpackPlugin from '../lib/index.js';

Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from 'path';
import path from 'node:path';
import extend from 'extend';
import { validate } from 'schema-utils';
import { Schema } from 'schema-utils/declarations/validate.js';
import type { Schema } from 'schema-utils/declarations/validate.js';
import svgstore from 'svgstore';
import webpack from 'webpack';
import type { Chunk, Compilation, Compiler, Module, NormalModule, sources } from 'webpack';
import templatePreview from './preview.js';
import unTypedSchemaOptions from './schemas/plugin-options.json' with { type: 'json' };
import {
import type {
EntryCache,
PluginOptions,
Sprite,
Expand Down Expand Up @@ -237,7 +237,7 @@ class SvgChunkWebpackPlugin {
)
);
for (const module of modules) {
if (module.buildInfo && module.buildInfo.SVG_CHUNK_WEBPACK_PLUGIN) {
if (module.buildInfo?.SVG_CHUNK_WEBPACK_PLUGIN) {
listSvgsDependencies.push(module as NormalModule);

// Mark module as not side effect free after processing in graph
Expand Down
6 changes: 3 additions & 3 deletions src/loader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { validate } from 'schema-utils';
import { Schema } from 'schema-utils/declarations/validate.js';
import type { Schema } from 'schema-utils/declarations/validate.js';
import { loadConfig, optimize } from 'svgo';
import unTypedSchemaOptions from './schemas/loader-options.json' with { type: 'json' };
import { LoaderOptions, LoaderThis } from './types.js';
import type { LoaderOptions, LoaderThis } from './types.js';
import { PACKAGE_NAME } from './utils.js';

const schemaOptions = unTypedSchemaOptions as Schema;
Expand Down Expand Up @@ -49,7 +49,7 @@ export default async function SvgChunkWebpackLoader(

try {
const { configFile } = options;
let config;
let config = null;
if (typeof configFile === 'string') {
try {
config = await loadConfig(configFile, this.context);
Expand Down
2 changes: 1 addition & 1 deletion src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sprite } from './types.js';
import type { Sprite } from './types.js';

export default function templatePreview(sprites: Sprite[]): string {
return `<!DOCTYPE html>
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { fileURLToPath } from 'url';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

export const PACKAGE_NAME = 'svg-chunk-webpack-plugin' as const;

Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';
import SvgChunkWebpackPlugin from '@src/index';
import templatePreview from '@src/preview';
import schemaOptions from '@src/schemas/plugin-options.json';
Expand Down
4 changes: 1 addition & 3 deletions tests/loader.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import loader from '@src/loader';
import schemaOptions from '@src/schemas/loader-options.json';
import { PACKAGE_NAME } from '@src/utils';
Expand Down Expand Up @@ -86,7 +84,7 @@ describe('Loader', () => {
});

it('Should call the loader function without factoryMeta object data', async () => {
delete _this._module.factoryMeta;
_this._module.factoryMeta = undefined;
await loader.call(_this, '<svg></svg>');
});
});
Expand Down
2 changes: 0 additions & 2 deletions tests/preview.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import preview from '@src/preview';

let previewSprite;
Expand Down

0 comments on commit 01bbb29

Please sign in to comment.