@venizia/dev-configs 0.4.8-2 → 0.4.8-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/cli/codemod/async-style.d.ts +2 -2
- package/dist/cli/codemod/async-style.js +4 -2
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/rewriter.js +1 -1
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
- package/dist/linters/eslint.js +6 -1
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/async-rules.d.ts +1 -1
- package/dist/linters/house/async-rules.js +3 -1
- package/dist/linters/house/async-rules.js.map +1 -1
- package/dist/linters/house/await-support.js +45 -38
- package/dist/linters/house/await-support.js.map +1 -1
- package/dist/linters/house/common.d.ts +43 -0
- package/dist/linters/house/common.js +43 -0
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.js +9 -8
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/hook-support.js +11 -7
- package/dist/linters/house/hook-support.js.map +1 -1
- package/dist/linters/house/index.d.ts +1 -0
- package/dist/linters/house/index.js +1 -0
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.js +12 -11
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-await-new-chain.rule.d.ts +37 -0
- package/dist/linters/house/no-await-new-chain.rule.js +179 -0
- package/dist/linters/house/no-await-new-chain.rule.js.map +1 -0
- package/dist/linters/house/no-await-promise-chain.rule.js +23 -22
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
- package/dist/linters/house/no-inline-await.rule.js +4 -3
- package/dist/linters/house/no-inline-await.rule.js.map +1 -1
- package/dist/linters/house/no-leaked-render.rule.js +3 -3
- package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.js +1 -1
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/house/no-return-await.rule.js +5 -4
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-silent-catch.rule.js +4 -3
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
- package/dist/linters/house/plugin.js +2 -0
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/promise-chain-support.js +25 -25
- package/dist/linters/house/promise-chain-support.js.map +1 -1
- package/dist/linters/oxlint.d.ts +6 -5
- package/dist/linters/oxlint.js +8 -3
- package/dist/linters/oxlint.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-chain-support.js","sourceRoot":"","sources":["../../../src/linters/house/promise-chain-support.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5D,4HAA4H;AAC5H,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC,CAAC;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE,4HAA4H;AAC5H,MAAa,mBAAmB;IAC9B,mHAAmH;IACnH,MAAM,CAAC,MAAM,CAAC,IAAuB;QACnC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,OAAO,cAAc,CAAC,GAAG,CAAC,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACpE,OAAO,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;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AO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvC,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CACL,IAAI,KAAK,kBAAkB;YAC3B,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,KAAK,IAAI;YACrD,mBAAmB,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CACxF,CAAC;IACJ,CAAC;IAED,wGAAwG;IACxG,MAAM,CAAC,WAAW,CAAC,IAAuB;QACxC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,OACE,cAAc,CAAC,GAAG,CAAC,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAC5D,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,iBAAiB,EACxD,CAAC;YACD,OAAO,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAtOD,kDAsOC","sourcesContent":["import { AstNode } from './common';\n\nconst CHAIN_METHODS = new Set(['then', 'catch', 'finally']);\n/** Wrappers that leave the value of the expression they hold unchanged: `x!`, `x as T`, `x satisfies T`, `<T>x`, `a?.b`. */\nconst VALUE_WRAPPERS = new Set([\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n 'ChainExpression',\n]);\nconst CONSTANT_UNARY_OPERATORS = new Set(['-', '+', '!', 'void']);\n\n/** The shared parts of the promise chain rules: what a chain call is, what a constant is, what a silent handler body is. */\nexport class PromiseChainSupport {\n /** `node` without the wrappers that do not change its value (`!`, `as`, `satisfies`, `<T>`, an optional chain). */\n static unwrap(opts: { node: unknown }): unknown {\n let current = opts.node;\n\n while (VALUE_WRAPPERS.has(AstNode.getType({ node: current }) ?? '')) {\n current = AstNode.readField({ node: current, key: 'expression' });\n }\n\n return current;\n }\n\n /** The name a member access reads: `a.name`, `a['name']`, ``a[`name`]``; `undefined` for a computed key. */\n static memberName(opts: { member: unknown }): string | undefined {\n const { member } = opts;\n const property = AstNode.readField({ node: member, key: 'property' });\n\n if (AstNode.readField({ node: member, key: 'computed' }) !== true) {\n const name = AstNode.readField({ node: property, key: 'name' });\n\n return typeof name === 'string' ? name : undefined;\n }\n\n if (AstNode.getType({ node: property }) === 'Literal') {\n const value = AstNode.readField({ node: property, key: 'value' });\n\n return typeof value === 'string' ? value : undefined;\n }\n\n const expressions = AstNode.readField({ node: property, key: 'expressions' });\n const quasis = AstNode.readField({ node: property, key: 'quasis' });\n\n if (\n AstNode.getType({ node: property }) === 'TemplateLiteral' &&\n Array.isArray(expressions) &&\n expressions.length === 0 &&\n Array.isArray(quasis)\n ) {\n const cooked = AstNode.readField({\n node: AstNode.readField({ node: quasis[0], key: 'value' }),\n key: 'cooked',\n });\n\n return typeof cooked === 'string' ? cooked : undefined;\n }\n\n return undefined;\n }\n\n /**\n * `then`, `catch` or `finally` when `node` (after `unwrap`) is a call of that method - `p.then(f)`, `p?.catch(f)`,\n * `p['finally'](f)` - and `undefined` for anything else. It reads the syntax only, so a thenable counts too.\n */\n static chainMethodOf(opts: { node: unknown }): string | undefined {\n const call = PromiseChainSupport.unwrap({ node: opts.node });\n\n if (AstNode.getType({ node: call }) !== 'CallExpression') {\n return undefined;\n }\n\n const callee = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: call, key: 'callee' }),\n });\n\n if (AstNode.getType({ node: callee }) !== 'MemberExpression') {\n return undefined;\n }\n\n const name = PromiseChainSupport.memberName({ member: callee });\n\n return name !== undefined && CHAIN_METHODS.has(name) ? name : undefined;\n }\n\n /**\n * Whether a chain call (`.then`, `.catch`, `.finally`) sits anywhere on the spine of `node`: the receivers and\n * callees a call chain is built from (`a.then(f).limit(1)` has one, `a.where(x).limit(1)` has none).\n */\n static hasChainOnSpine(opts: { node: unknown }): boolean {\n let current = PromiseChainSupport.unwrap({ node: opts.node });\n\n for (;;) {\n const type = AstNode.getType({ node: current });\n\n if (type === 'CallExpression') {\n if (PromiseChainSupport.chainMethodOf({ node: current }) !== undefined) {\n return true;\n }\n\n current = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: current, key: 'callee' }),\n });\n continue;\n }\n\n if (type === 'MemberExpression') {\n current = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: current, key: 'object' }),\n });\n continue;\n }\n\n return false;\n }\n }\n\n /**\n * A value that is the same every time and reads nothing: a literal, `undefined`, a template with no `${}`, `-1`,\n * `void 0`, and an array or object literal built only from those (`[]`, `{}`, `{ items: [] }`).\n */\n static isConstant(opts: { node: unknown }): boolean {\n const node = PromiseChainSupport.unwrapTypes({ node: opts.node });\n const type = AstNode.getType({ node }) ?? '';\n const constant = (child: unknown) => PromiseChainSupport.isConstant({ node: child });\n\n switch (type) {\n case 'Literal': {\n return true;\n }\n case 'Identifier': {\n return AstNode.readField({ node, key: 'name' }) === 'undefined';\n }\n case 'TemplateLiteral': {\n const expressions = AstNode.readField({ node, key: 'expressions' });\n\n return Array.isArray(expressions) && expressions.length === 0;\n }\n case 'UnaryExpression': {\n return (\n CONSTANT_UNARY_OPERATORS.has(String(AstNode.readField({ node, key: 'operator' }))) &&\n constant(AstNode.readField({ node, key: 'argument' }))\n );\n }\n case 'ArrayExpression': {\n const elements = AstNode.readField({ node, key: 'elements' });\n\n return (\n Array.isArray(elements) &&\n elements.every((element) => element === null || constant(element))\n );\n }\n case 'ObjectExpression': {\n const properties = AstNode.readField({ node, key: 'properties' });\n\n return (\n Array.isArray(properties) &&\n properties.every(\n (property) =>\n AstNode.getType({ node: property }) === 'Property' &&\n AstNode.readField({ node: property, key: 'computed' }) !== true &&\n AstNode.readField({ node: property, key: 'method' }) !== true &&\n AstNode.readField({ node: property, key: 'kind' }) === 'init' &&\n constant(AstNode.readField({ node: property, key: 'value' })),\n )\n );\n }\n default: {\n return false;\n }\n }\n }\n\n /**\n * Whether the statements of a handler or a `catch` block leave no trace of the error: none at all (a comment does\n * not count), or only `return;`, `return <constant>;` and `<name or member> = <constant>;`. Anything else - a\n * call, a `throw`, a read of a variable - is a decision someone made, and counts as handled.\n */\n static isSilentBlock(opts: { statements: unknown }): boolean {\n const { statements } = opts;\n\n return (\n Array.isArray(statements) &&\n statements.every((statement) => {\n const type = AstNode.getType({ node: statement });\n\n if (type === 'EmptyStatement') {\n return true;\n }\n\n if (type === 'ReturnStatement') {\n const argument = AstNode.readField({ node: statement, key: 'argument' });\n\n return argument === null || PromiseChainSupport.isConstant({ node: argument });\n }\n\n const expression = AstNode.readField({ node: statement, key: 'expression' });\n\n return (\n type === 'ExpressionStatement' &&\n AstNode.getType({ node: expression }) === 'AssignmentExpression' &&\n AstNode.readField({ node: expression, key: 'operator' }) === '=' &&\n PromiseChainSupport.isPlainTarget({\n node: AstNode.readField({ node: expression, key: 'left' }),\n }) &&\n PromiseChainSupport.isConstant({\n node: AstNode.readField({ node: expression, key: 'right' }),\n })\n );\n })\n );\n }\n\n /** `name`, `this.name`, `a.b.c`: an assignment target that reads no computed key and calls nothing. */\n static isPlainTarget(opts: { node: unknown }): boolean {\n const { node } = opts;\n const type = AstNode.getType({ node });\n\n if (type === 'Identifier' || type === 'ThisExpression') {\n return true;\n }\n\n return (\n type === 'MemberExpression' &&\n AstNode.readField({ node, key: 'computed' }) !== true &&\n PromiseChainSupport.isPlainTarget({ node: AstNode.readField({ node, key: 'object' }) })\n );\n }\n\n /** `node` without the type-only wrappers (`as`, `satisfies`, `!`, `<T>`), keeping an optional chain. */\n static unwrapTypes(opts: { node: unknown }): unknown {\n let current = opts.node;\n\n while (\n VALUE_WRAPPERS.has(AstNode.getType({ node: current }) ?? '') &&\n AstNode.getType({ node: current }) !== 'ChainExpression'\n ) {\n current = AstNode.readField({ node: current, key: 'expression' });\n }\n\n return current;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"promise-chain-support.js","sourceRoot":"","sources":["../../../src/linters/house/promise-chain-support.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AAEjD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5D,4HAA4H;AAC5H,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,qBAAY,CAAC,aAAa;IAC1B,qBAAY,CAAC,oBAAoB;IACjC,qBAAY,CAAC,mBAAmB;IAChC,qBAAY,CAAC,cAAc;IAC3B,qBAAY,CAAC,gBAAgB;CAC9B,CAAC,CAAC;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE,4HAA4H;AAC5H,MAAa,mBAAmB;IAC9B,mHAAmH;IACnH,MAAM,CAAC,MAAM,CAAC,IAAuB;QACnC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,OAAO,cAAc,CAAC,GAAG,CAAC,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACpE,OAAO,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,4GAA4G;IAC5G,MAAM,CAAC,UAAU,CAAC,IAAyB;QACzC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CA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AuB;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,MAAM,IAAI,GAAG,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvC,IAAI,IAAI,KAAK,qBAAY,CAAC,UAAU,IAAI,IAAI,KAAK,qBAAY,CAAC,eAAe,EAAE,CAAC;YAC9E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CACL,IAAI,KAAK,qBAAY,CAAC,iBAAiB;YACvC,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,KAAK,IAAI;YACrD,mBAAmB,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CACxF,CAAC;IACJ,CAAC;IAED,wGAAwG;IACxG,MAAM,CAAC,WAAW,CAAC,IAAuB;QACxC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QAExB,OACE,cAAc,CAAC,GAAG,CAAC,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YAC5D,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,qBAAY,CAAC,gBAAgB,EACpE,CAAC;YACD,OAAO,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAtOD,kDAsOC","sourcesContent":["import { AstNode, AstNodeTypes } from './common';\n\nconst CHAIN_METHODS = new Set(['then', 'catch', 'finally']);\n/** Wrappers that leave the value of the expression they hold unchanged: `x!`, `x as T`, `x satisfies T`, `<T>x`, `a?.b`. */\nconst VALUE_WRAPPERS = new Set([\n AstNodeTypes.AS_EXPRESSION,\n AstNodeTypes.SATISFIES_EXPRESSION,\n AstNodeTypes.NON_NULL_EXPRESSION,\n AstNodeTypes.TYPE_ASSERTION,\n AstNodeTypes.CHAIN_EXPRESSION,\n]);\nconst CONSTANT_UNARY_OPERATORS = new Set(['-', '+', '!', 'void']);\n\n/** The shared parts of the promise chain rules: what a chain call is, what a constant is, what a silent handler body is. */\nexport class PromiseChainSupport {\n /** `node` without the wrappers that do not change its value (`!`, `as`, `satisfies`, `<T>`, an optional chain). */\n static unwrap(opts: { node: unknown }): unknown {\n let current = opts.node;\n\n while (VALUE_WRAPPERS.has(AstNode.getType({ node: current }) ?? '')) {\n current = AstNode.readField({ node: current, key: 'expression' });\n }\n\n return current;\n }\n\n /** The name a member access reads: `a.name`, `a['name']`, ``a[`name`]``; `undefined` for a computed key. */\n static memberName(opts: { member: unknown }): string | undefined {\n const { member } = opts;\n const property = AstNode.readField({ node: member, key: 'property' });\n\n if (AstNode.readField({ node: member, key: 'computed' }) !== true) {\n const name = AstNode.readField({ node: property, key: 'name' });\n\n return typeof name === 'string' ? name : undefined;\n }\n\n if (AstNode.getType({ node: property }) === AstNodeTypes.LITERAL) {\n const value = AstNode.readField({ node: property, key: 'value' });\n\n return typeof value === 'string' ? value : undefined;\n }\n\n const expressions = AstNode.readField({ node: property, key: 'expressions' });\n const quasis = AstNode.readField({ node: property, key: 'quasis' });\n\n if (\n AstNode.getType({ node: property }) === AstNodeTypes.TEMPLATE_LITERAL &&\n Array.isArray(expressions) &&\n expressions.length === 0 &&\n Array.isArray(quasis)\n ) {\n const cooked = AstNode.readField({\n node: AstNode.readField({ node: quasis[0], key: 'value' }),\n key: 'cooked',\n });\n\n return typeof cooked === 'string' ? cooked : undefined;\n }\n\n return undefined;\n }\n\n /**\n * `then`, `catch` or `finally` when `node` (after `unwrap`) is a call of that method - `p.then(f)`, `p?.catch(f)`,\n * `p['finally'](f)` - and `undefined` for anything else. It reads the syntax only, so a thenable counts too.\n */\n static chainMethodOf(opts: { node: unknown }): string | undefined {\n const call = PromiseChainSupport.unwrap({ node: opts.node });\n\n if (AstNode.getType({ node: call }) !== AstNodeTypes.CALL_EXPRESSION) {\n return undefined;\n }\n\n const callee = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: call, key: 'callee' }),\n });\n\n if (AstNode.getType({ node: callee }) !== AstNodeTypes.MEMBER_EXPRESSION) {\n return undefined;\n }\n\n const name = PromiseChainSupport.memberName({ member: callee });\n\n return name !== undefined && CHAIN_METHODS.has(name) ? name : undefined;\n }\n\n /**\n * Whether a chain call (`.then`, `.catch`, `.finally`) sits anywhere on the spine of `node`: the receivers and\n * callees a call chain is built from (`a.then(f).limit(1)` has one, `a.where(x).limit(1)` has none).\n */\n static hasChainOnSpine(opts: { node: unknown }): boolean {\n let current = PromiseChainSupport.unwrap({ node: opts.node });\n\n for (;;) {\n const type = AstNode.getType({ node: current });\n\n if (type === AstNodeTypes.CALL_EXPRESSION) {\n if (PromiseChainSupport.chainMethodOf({ node: current }) !== undefined) {\n return true;\n }\n\n current = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: current, key: 'callee' }),\n });\n continue;\n }\n\n if (type === AstNodeTypes.MEMBER_EXPRESSION) {\n current = PromiseChainSupport.unwrap({\n node: AstNode.readField({ node: current, key: 'object' }),\n });\n continue;\n }\n\n return false;\n }\n }\n\n /**\n * A value that is the same every time and reads nothing: a literal, `undefined`, a template with no `${}`, `-1`,\n * `void 0`, and an array or object literal built only from those (`[]`, `{}`, `{ items: [] }`).\n */\n static isConstant(opts: { node: unknown }): boolean {\n const node = PromiseChainSupport.unwrapTypes({ node: opts.node });\n const type = AstNode.getType({ node }) ?? '';\n const constant = (child: unknown) => PromiseChainSupport.isConstant({ node: child });\n\n switch (type) {\n case AstNodeTypes.LITERAL: {\n return true;\n }\n case AstNodeTypes.IDENTIFIER: {\n return AstNode.readField({ node, key: 'name' }) === 'undefined';\n }\n case AstNodeTypes.TEMPLATE_LITERAL: {\n const expressions = AstNode.readField({ node, key: 'expressions' });\n\n return Array.isArray(expressions) && expressions.length === 0;\n }\n case AstNodeTypes.UNARY_EXPRESSION: {\n return (\n CONSTANT_UNARY_OPERATORS.has(String(AstNode.readField({ node, key: 'operator' }))) &&\n constant(AstNode.readField({ node, key: 'argument' }))\n );\n }\n case AstNodeTypes.ARRAY_EXPRESSION: {\n const elements = AstNode.readField({ node, key: 'elements' });\n\n return (\n Array.isArray(elements) &&\n elements.every((element) => element === null || constant(element))\n );\n }\n case AstNodeTypes.OBJECT_EXPRESSION: {\n const properties = AstNode.readField({ node, key: 'properties' });\n\n return (\n Array.isArray(properties) &&\n properties.every(\n (property) =>\n AstNode.getType({ node: property }) === AstNodeTypes.PROPERTY &&\n AstNode.readField({ node: property, key: 'computed' }) !== true &&\n AstNode.readField({ node: property, key: 'method' }) !== true &&\n AstNode.readField({ node: property, key: 'kind' }) === 'init' &&\n constant(AstNode.readField({ node: property, key: 'value' })),\n )\n );\n }\n default: {\n return false;\n }\n }\n }\n\n /**\n * Whether the statements of a handler or a `catch` block leave no trace of the error: none at all (a comment does\n * not count), or only `return;`, `return <constant>;` and `<name or member> = <constant>;`. Anything else - a\n * call, a `throw`, a read of a variable - is a decision someone made, and counts as handled.\n */\n static isSilentBlock(opts: { statements: unknown }): boolean {\n const { statements } = opts;\n\n return (\n Array.isArray(statements) &&\n statements.every((statement) => {\n const type = AstNode.getType({ node: statement });\n\n if (type === AstNodeTypes.EMPTY_STATEMENT) {\n return true;\n }\n\n if (type === AstNodeTypes.RETURN_STATEMENT) {\n const argument = AstNode.readField({ node: statement, key: 'argument' });\n\n return argument === null || PromiseChainSupport.isConstant({ node: argument });\n }\n\n const expression = AstNode.readField({ node: statement, key: 'expression' });\n\n return (\n type === AstNodeTypes.EXPRESSION_STATEMENT &&\n AstNode.getType({ node: expression }) === AstNodeTypes.ASSIGNMENT_EXPRESSION &&\n AstNode.readField({ node: expression, key: 'operator' }) === '=' &&\n PromiseChainSupport.isPlainTarget({\n node: AstNode.readField({ node: expression, key: 'left' }),\n }) &&\n PromiseChainSupport.isConstant({\n node: AstNode.readField({ node: expression, key: 'right' }),\n })\n );\n })\n );\n }\n\n /** `name`, `this.name`, `a.b.c`: an assignment target that reads no computed key and calls nothing. */\n static isPlainTarget(opts: { node: unknown }): boolean {\n const { node } = opts;\n const type = AstNode.getType({ node });\n\n if (type === AstNodeTypes.IDENTIFIER || type === AstNodeTypes.THIS_EXPRESSION) {\n return true;\n }\n\n return (\n type === AstNodeTypes.MEMBER_EXPRESSION &&\n AstNode.readField({ node, key: 'computed' }) !== true &&\n PromiseChainSupport.isPlainTarget({ node: AstNode.readField({ node, key: 'object' }) })\n );\n }\n\n /** `node` without the type-only wrappers (`as`, `satisfies`, `!`, `<T>`), keeping an optional chain. */\n static unwrapTypes(opts: { node: unknown }): unknown {\n let current = opts.node;\n\n while (\n VALUE_WRAPPERS.has(AstNode.getType({ node: current }) ?? '') &&\n AstNode.getType({ node: current }) !== AstNodeTypes.CHAIN_EXPRESSION\n ) {\n current = AstNode.readField({ node: current, key: 'expression' });\n }\n\n return current;\n }\n}\n"]}
|
package/dist/linters/oxlint.d.ts
CHANGED
|
@@ -15,16 +15,17 @@ import type { OxlintConfig } from 'oxlint';
|
|
|
15
15
|
* export default defineConfig(oxlintConfigs);
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* `
|
|
19
|
-
*
|
|
18
|
+
* `prefer-nullish-coalescing` allows `||` on a string (`name?.trim() || 'guest'`) and reports it on
|
|
19
|
+
* every other nullable type. `OxlintConfigs.create({ lenientFallback: true })` is the same preset
|
|
20
|
+
* with `||` allowed on number operands too.
|
|
20
21
|
*/
|
|
21
22
|
export declare const oxlintConfigs: OxlintConfig;
|
|
22
23
|
/** Options of `OxlintConfigs.create`. */
|
|
23
24
|
export interface IOxlintPresetOptions {
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Also allow `||` / `||=` where the left side is a number, so `limit || 20` passes: `0` falls
|
|
27
|
+
* back on purpose. A string is allowed by the base already. Left off, the base catches a real `0`
|
|
28
|
+
* swallowed by `||`.
|
|
28
29
|
*
|
|
29
30
|
* @default false
|
|
30
31
|
*/
|
package/dist/linters/oxlint.js
CHANGED
|
@@ -22,8 +22,9 @@ const JS_TS_FILES = ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx', ...TS_FILES]
|
|
|
22
22
|
* export default defineConfig(oxlintConfigs);
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
25
|
+
* `prefer-nullish-coalescing` allows `||` on a string (`name?.trim() || 'guest'`) and reports it on
|
|
26
|
+
* every other nullable type. `OxlintConfigs.create({ lenientFallback: true })` is the same preset
|
|
27
|
+
* with `||` allowed on number operands too.
|
|
27
28
|
*/
|
|
28
29
|
exports.oxlintConfigs = {
|
|
29
30
|
plugins: ['typescript', 'unicorn'],
|
|
@@ -124,7 +125,11 @@ exports.oxlintConfigs = {
|
|
|
124
125
|
// typescript-eslint, type-aware
|
|
125
126
|
'typescript/await-thenable': 'error',
|
|
126
127
|
'typescript/no-floating-promises': 'error',
|
|
127
|
-
|
|
128
|
+
// `||` on a string is mostly an intentional empty-string fallback (`value?.trim() || fallback`);
|
|
129
|
+
// `??` keeps `''` and changes behaviour. Objects and numbers still report.
|
|
130
|
+
[rules_1.PreferNullishCoalescingRule.NAME]: rules_1.PreferNullishCoalescingRule.build({
|
|
131
|
+
ignorePrimitives: { string: true },
|
|
132
|
+
}),
|
|
128
133
|
'typescript/return-await': 'error',
|
|
129
134
|
},
|
|
130
135
|
overrides: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../../src/linters/oxlint.ts"],"names":[],"mappings":";;;AACA,qCAAsC;AACtC,mCAMiB;AAEjB,0CAA0C;AAC1C,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,UAAU,E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AA6F;gBAC7F,8FAA8F;gBAC9F,2FAA2F;gBAC3F,oCAAoC,EAAE;oBACpC,OAAO;oBACP;wBACE,MAAM,EAAE,cAAc;wBACtB,QAAQ,EAAE,qBAAqB;wBAC/B,uBAAuB,EAAE,KAAK;qBAC/B;iBACF;aACF;SACF;QACD;YACE,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE;gBACL,uBAAuB,EAAE,KAAK;gBAC9B,cAAc,EAAE,OAAO;gBACvB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;gBACvB,CAAC,+BAAuB,CAAC,IAAI,CAAC,EAAE,+BAAuB,CAAC,KAAK,EAAE;gBAC/D,oCAAoC,EAAE,KAAK;gBAC3C,0BAA0B,EAAE,KAAK;gBACjC,iCAAiC,EAAE,KAAK;aACzC;SACF;KACF;CACF,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,MAAa,aAAa;IACxB,MAAM,CAAC,MAAM,CAAC,OAA6B,EAAE;QAC3C,MAAM,MAAM,GAAiB,IAAI,CAAC,eAAe;YAC/C,CAAC,CAAC;gBACE,GAAG,qBAAa;gBAChB,KAAK,EAAE;oBACL,GAAG,qBAAa,CAAC,KAAK;oBACtB,CAAC,mCAA2B,CAAC,IAAI,CAAC,EAAE,mCAA2B,CAAC,KAAK,CAAC;wBACpE,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;qBACjD,CAAC;iBACH;aACF;YACH,CAAC,CAAC,qBAAa,CAAC;QAElB,OAAO,mBAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AAhBD,sCAgBC","sourcesContent":["import type { OxlintConfig } from 'oxlint';\nimport { LintIgnore } from './ignore';\nimport {\n EqeqeqRule,\n NoRestrictedImportsRule,\n NoUnusedVarsRule,\n PreferNullishCoalescingRule,\n SwitchCaseBracesRule,\n} from './rules';\n\n/** File globs the rules are scoped to. */\nconst TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];\nconst JS_TS_FILES = ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx', ...TS_FILES];\n\n/**\n * The oxlint port of `eslintConfigs`, generated with `@oxlint/migrate` and kept rule for rule.\n * Type-aware rules (`no-floating-promises`, `return-await`, ...) need `oxlint-tsgolint` installed.\n *\n * Not ported: `@typescript-eslint/naming-convention` (oxlint has no equivalent yet - keep it in\n * ESLint), `@typescript-eslint/prefer-optional-chain` (oxlint nursery), `no-invalid-this` (covered\n * by `noImplicitThis` in `tsconfig.base.json`). `n/prefer-node-protocol` maps to the unicorn rule.\n *\n * ```ts\n * // .configs/lints/oxlint.config.mts\n * import { defineConfig } from 'oxlint';\n * import { oxlintConfigs } from '@venizia/dev-configs/linters/oxlint';\n *\n * export default defineConfig(oxlintConfigs);\n * ```\n *\n * `OxlintConfigs.create({ lenientFallback: true })` is the same preset with `||` allowed on string\n * and number operands.\n */\nexport const oxlintConfigs: OxlintConfig = {\n plugins: ['typescript', 'unicorn'],\n categories: { correctness: 'off' },\n options: { typeAware: true },\n env: { builtin: true },\n ignorePatterns: ['**/node_modules/', '**/*.d.ts', '**/build/', '**/dist/', '**/release/'],\n rules: {\n // eslint:recommended\n 'constructor-super': 'error',\n 'for-direction': 'error',\n 'getter-return': 'error',\n 'no-async-promise-executor': 'error',\n 'no-case-declarations': 'error',\n 'no-class-assign': 'error',\n 'no-compare-neg-zero': 'error',\n 'no-cond-assign': 'error',\n 'no-const-assign': 'error',\n 'no-constant-binary-expression': 'error',\n 'no-constant-condition': 'error',\n 'no-control-regex': 'error',\n 'no-debugger': 'error',\n 'no-delete-var': 'error',\n 'no-dupe-else-if': 'error',\n 'no-dupe-keys': 'error',\n 'no-duplicate-case': 'error',\n 'no-empty': 'error',\n 'no-empty-character-class': 'error',\n 'no-empty-pattern': 'error',\n 'no-empty-static-block': 'error',\n 'no-ex-assign': 'error',\n 'no-extra-boolean-cast': 'error',\n 'no-fallthrough': 'error',\n 'no-func-assign': 'error',\n 'no-global-assign': 'error',\n 'no-import-assign': 'error',\n 'no-invalid-regexp': 'error',\n 'no-irregular-whitespace': 'error',\n 'no-loss-of-precision': 'error',\n 'no-misleading-character-class': 'error',\n 'no-new-native-nonconstructor': 'error',\n 'no-nonoctal-decimal-escape': 'error',\n 'no-obj-calls': 'error',\n 'no-prototype-builtins': 'error',\n 'no-regex-spaces': 'error',\n 'no-self-assign': 'error',\n 'no-setter-return': 'error',\n 'no-shadow-restricted-names': 'error',\n 'no-sparse-arrays': 'error',\n 'no-this-before-super': 'error',\n 'no-unassigned-vars': 'error',\n 'no-unreachable': 'error',\n 'no-unsafe-finally': 'error',\n 'no-unsafe-negation': 'error',\n 'no-unsafe-optional-chaining': 'error',\n 'no-unused-labels': 'error',\n 'no-unused-private-class-members': 'error',\n 'no-useless-backreference': 'error',\n 'no-useless-catch': 'error',\n 'no-with': 'error',\n 'preserve-caught-error': 'error',\n 'require-yield': 'error',\n 'use-isnan': 'error',\n 'valid-typeof': 'error',\n 'no-array-constructor': 'error',\n\n // Strict rules on top\n [NoUnusedVarsRule.NAME]: NoUnusedVarsRule.build(),\n 'no-useless-escape': 'warn',\n 'no-unused-expressions': 'error',\n 'no-new-wrappers': 'error',\n 'no-throw-literal': 'error',\n [EqeqeqRule.NAME]: EqeqeqRule.build(),\n 'no-void': 'error',\n 'no-caller': 'error',\n 'no-shadow': 'error',\n 'no-use-before-define': 'error',\n [SwitchCaseBracesRule.NAME]: SwitchCaseBracesRule.build(),\n 'unicorn/prefer-node-protocol': 'error',\n\n // typescript-eslint\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-duplicate-enum-values': 'error',\n 'typescript/no-empty-object-type': 'error',\n 'typescript/no-extra-non-null-assertion': 'error',\n 'typescript/no-misused-new': 'error',\n 'typescript/no-namespace': 'error',\n 'typescript/no-non-null-asserted-optional-chain': 'error',\n 'typescript/no-this-alias': 'error',\n 'typescript/no-unnecessary-type-constraint': 'error',\n 'typescript/no-unsafe-declaration-merging': 'error',\n 'typescript/no-unsafe-function-type': 'error',\n 'typescript/no-wrapper-object-types': 'error',\n 'typescript/prefer-as-const': 'error',\n 'typescript/prefer-namespace-keyword': 'error',\n 'typescript/triple-slash-reference': 'error',\n 'typescript/adjacent-overload-signatures': 'error',\n 'typescript/prefer-for-of': 'error',\n 'typescript/unified-signatures': 'error',\n\n // typescript-eslint, type-aware\n 'typescript/await-thenable': 'error',\n 'typescript/no-floating-promises': 'error',\n [PreferNullishCoalescingRule.NAME]: PreferNullishCoalescingRule.build(),\n 'typescript/return-await': 'error',\n },\n overrides: [\n {\n // TypeScript itself reports these.\n files: TS_FILES,\n rules: {\n 'constructor-super': 'off',\n 'getter-return': 'off',\n 'no-class-assign': 'off',\n 'no-const-assign': 'off',\n 'no-dupe-keys': 'off',\n 'no-func-assign': 'off',\n 'no-import-assign': 'off',\n 'no-new-native-nonconstructor': 'off',\n 'no-obj-calls': 'off',\n 'no-setter-return': 'off',\n 'no-this-before-super': 'off',\n 'no-unreachable': 'off',\n 'no-unsafe-negation': 'off',\n 'no-with': 'off',\n 'no-var': 'error',\n 'prefer-const': 'error',\n 'prefer-rest-params': 'error',\n 'prefer-spread': 'error',\n // A value import of a type becomes a runtime import when Bun runs a decorated class's source\n // (emitDecoratorMetadata) and fails with `Export named 'X' not found`. `import('pkg').T` type\n // annotations stay allowed: they are type-only by construction, and type an optional peer.\n 'typescript/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n fixStyle: 'inline-type-imports',\n disallowTypeAnnotations: false,\n },\n ],\n },\n },\n {\n files: JS_TS_FILES,\n rules: {\n 'no-constant-condition': 'off',\n 'prefer-const': 'error',\n 'no-var': 'error',\n curly: ['error', 'all'],\n [NoRestrictedImportsRule.NAME]: NoRestrictedImportsRule.build(),\n 'typescript/no-unsafe-function-type': 'off',\n 'typescript/no-this-alias': 'off',\n 'typescript/no-empty-object-type': 'off',\n },\n },\n ],\n};\n\n/** Options of `OxlintConfigs.create`. */\nexport interface IOxlintPresetOptions {\n /**\n * Allow `||` / `||=` where the left side is a string or a number, so `name || 'guest'` and\n * `limit || 20` pass: `''` and `0` fall back on purpose. Left off, the base catches a real\n * `''` or `0` swallowed by `||`.\n *\n * @default false\n */\n lenientFallback?: boolean;\n /**\n * Project paths to skip - generated files, vendored code - as in `--ignore-pattern`: `src/gen/**`.\n * Every rule is turned off for them (oxlint cannot ignore a project path from `.configs/`).\n * Share the list with ESLint through `LintIgnore`.\n *\n * @default []\n */\n ignore?: string[];\n}\n\n/**\n * Builds `oxlintConfigs` with options. Without any it returns the base preset unchanged.\n *\n * ```ts\n * // .configs/lints/oxlint.config.mts\n * import { defineConfig } from 'oxlint';\n * import { OxlintConfigs } from '@venizia/dev-configs/linters/oxlint';\n *\n * export default defineConfig(OxlintConfigs.create({ lenientFallback: true }));\n * ```\n */\nexport class OxlintConfigs {\n static create(opts: IOxlintPresetOptions = {}): OxlintConfig {\n const config: OxlintConfig = opts.lenientFallback\n ? {\n ...oxlintConfigs,\n rules: {\n ...oxlintConfigs.rules,\n [PreferNullishCoalescingRule.NAME]: PreferNullishCoalescingRule.build({\n ignorePrimitives: { string: true, number: true },\n }),\n },\n }\n : oxlintConfigs;\n\n return LintIgnore.oxlint({ config, patterns: opts.ignore ?? [] });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../../src/linters/oxlint.ts"],"names":[],"mappings":";;;AACA,qCAAsC;AACtC,mCAMiB;AAEjB,0CAA0C;AAC1C,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACjE,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,CAAC;AAEjF;;;;;;;;;;;;;;;;;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AO;oBACP;wBACE,MAAM,EAAE,cAAc;wBACtB,QAAQ,EAAE,qBAAqB;wBAC/B,uBAAuB,EAAE,KAAK;qBAC/B;iBACF;aACF;SACF;QACD;YACE,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE;gBACL,uBAAuB,EAAE,KAAK;gBAC9B,cAAc,EAAE,OAAO;gBACvB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;gBACvB,CAAC,+BAAuB,CAAC,IAAI,CAAC,EAAE,+BAAuB,CAAC,KAAK,EAAE;gBAC/D,oCAAoC,EAAE,KAAK;gBAC3C,0BAA0B,EAAE,KAAK;gBACjC,iCAAiC,EAAE,KAAK;aACzC;SACF;KACF;CACF,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,MAAa,aAAa;IACxB,MAAM,CAAC,MAAM,CAAC,OAA6B,EAAE;QAC3C,MAAM,MAAM,GAAiB,IAAI,CAAC,eAAe;YAC/C,CAAC,CAAC;gBACE,GAAG,qBAAa;gBAChB,KAAK,EAAE;oBACL,GAAG,qBAAa,CAAC,KAAK;oBACtB,CAAC,mCAA2B,CAAC,IAAI,CAAC,EAAE,mCAA2B,CAAC,KAAK,CAAC;wBACpE,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;qBACjD,CAAC;iBACH;aACF;YACH,CAAC,CAAC,qBAAa,CAAC;QAElB,OAAO,mBAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AAhBD,sCAgBC","sourcesContent":["import type { OxlintConfig } from 'oxlint';\nimport { LintIgnore } from './ignore';\nimport {\n EqeqeqRule,\n NoRestrictedImportsRule,\n NoUnusedVarsRule,\n PreferNullishCoalescingRule,\n SwitchCaseBracesRule,\n} from './rules';\n\n/** File globs the rules are scoped to. */\nconst TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];\nconst JS_TS_FILES = ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx', ...TS_FILES];\n\n/**\n * The oxlint port of `eslintConfigs`, generated with `@oxlint/migrate` and kept rule for rule.\n * Type-aware rules (`no-floating-promises`, `return-await`, ...) need `oxlint-tsgolint` installed.\n *\n * Not ported: `@typescript-eslint/naming-convention` (oxlint has no equivalent yet - keep it in\n * ESLint), `@typescript-eslint/prefer-optional-chain` (oxlint nursery), `no-invalid-this` (covered\n * by `noImplicitThis` in `tsconfig.base.json`). `n/prefer-node-protocol` maps to the unicorn rule.\n *\n * ```ts\n * // .configs/lints/oxlint.config.mts\n * import { defineConfig } from 'oxlint';\n * import { oxlintConfigs } from '@venizia/dev-configs/linters/oxlint';\n *\n * export default defineConfig(oxlintConfigs);\n * ```\n *\n * `prefer-nullish-coalescing` allows `||` on a string (`name?.trim() || 'guest'`) and reports it on\n * every other nullable type. `OxlintConfigs.create({ lenientFallback: true })` is the same preset\n * with `||` allowed on number operands too.\n */\nexport const oxlintConfigs: OxlintConfig = {\n plugins: ['typescript', 'unicorn'],\n categories: { correctness: 'off' },\n options: { typeAware: true },\n env: { builtin: true },\n ignorePatterns: ['**/node_modules/', '**/*.d.ts', '**/build/', '**/dist/', '**/release/'],\n rules: {\n // eslint:recommended\n 'constructor-super': 'error',\n 'for-direction': 'error',\n 'getter-return': 'error',\n 'no-async-promise-executor': 'error',\n 'no-case-declarations': 'error',\n 'no-class-assign': 'error',\n 'no-compare-neg-zero': 'error',\n 'no-cond-assign': 'error',\n 'no-const-assign': 'error',\n 'no-constant-binary-expression': 'error',\n 'no-constant-condition': 'error',\n 'no-control-regex': 'error',\n 'no-debugger': 'error',\n 'no-delete-var': 'error',\n 'no-dupe-else-if': 'error',\n 'no-dupe-keys': 'error',\n 'no-duplicate-case': 'error',\n 'no-empty': 'error',\n 'no-empty-character-class': 'error',\n 'no-empty-pattern': 'error',\n 'no-empty-static-block': 'error',\n 'no-ex-assign': 'error',\n 'no-extra-boolean-cast': 'error',\n 'no-fallthrough': 'error',\n 'no-func-assign': 'error',\n 'no-global-assign': 'error',\n 'no-import-assign': 'error',\n 'no-invalid-regexp': 'error',\n 'no-irregular-whitespace': 'error',\n 'no-loss-of-precision': 'error',\n 'no-misleading-character-class': 'error',\n 'no-new-native-nonconstructor': 'error',\n 'no-nonoctal-decimal-escape': 'error',\n 'no-obj-calls': 'error',\n 'no-prototype-builtins': 'error',\n 'no-regex-spaces': 'error',\n 'no-self-assign': 'error',\n 'no-setter-return': 'error',\n 'no-shadow-restricted-names': 'error',\n 'no-sparse-arrays': 'error',\n 'no-this-before-super': 'error',\n 'no-unassigned-vars': 'error',\n 'no-unreachable': 'error',\n 'no-unsafe-finally': 'error',\n 'no-unsafe-negation': 'error',\n 'no-unsafe-optional-chaining': 'error',\n 'no-unused-labels': 'error',\n 'no-unused-private-class-members': 'error',\n 'no-useless-backreference': 'error',\n 'no-useless-catch': 'error',\n 'no-with': 'error',\n 'preserve-caught-error': 'error',\n 'require-yield': 'error',\n 'use-isnan': 'error',\n 'valid-typeof': 'error',\n 'no-array-constructor': 'error',\n\n // Strict rules on top\n [NoUnusedVarsRule.NAME]: NoUnusedVarsRule.build(),\n 'no-useless-escape': 'warn',\n 'no-unused-expressions': 'error',\n 'no-new-wrappers': 'error',\n 'no-throw-literal': 'error',\n [EqeqeqRule.NAME]: EqeqeqRule.build(),\n 'no-void': 'error',\n 'no-caller': 'error',\n 'no-shadow': 'error',\n 'no-use-before-define': 'error',\n [SwitchCaseBracesRule.NAME]: SwitchCaseBracesRule.build(),\n 'unicorn/prefer-node-protocol': 'error',\n\n // typescript-eslint\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-duplicate-enum-values': 'error',\n 'typescript/no-empty-object-type': 'error',\n 'typescript/no-extra-non-null-assertion': 'error',\n 'typescript/no-misused-new': 'error',\n 'typescript/no-namespace': 'error',\n 'typescript/no-non-null-asserted-optional-chain': 'error',\n 'typescript/no-this-alias': 'error',\n 'typescript/no-unnecessary-type-constraint': 'error',\n 'typescript/no-unsafe-declaration-merging': 'error',\n 'typescript/no-unsafe-function-type': 'error',\n 'typescript/no-wrapper-object-types': 'error',\n 'typescript/prefer-as-const': 'error',\n 'typescript/prefer-namespace-keyword': 'error',\n 'typescript/triple-slash-reference': 'error',\n 'typescript/adjacent-overload-signatures': 'error',\n 'typescript/prefer-for-of': 'error',\n 'typescript/unified-signatures': 'error',\n\n // typescript-eslint, type-aware\n 'typescript/await-thenable': 'error',\n 'typescript/no-floating-promises': 'error',\n // `||` on a string is mostly an intentional empty-string fallback (`value?.trim() || fallback`);\n // `??` keeps `''` and changes behaviour. Objects and numbers still report.\n [PreferNullishCoalescingRule.NAME]: PreferNullishCoalescingRule.build({\n ignorePrimitives: { string: true },\n }),\n 'typescript/return-await': 'error',\n },\n overrides: [\n {\n // TypeScript itself reports these.\n files: TS_FILES,\n rules: {\n 'constructor-super': 'off',\n 'getter-return': 'off',\n 'no-class-assign': 'off',\n 'no-const-assign': 'off',\n 'no-dupe-keys': 'off',\n 'no-func-assign': 'off',\n 'no-import-assign': 'off',\n 'no-new-native-nonconstructor': 'off',\n 'no-obj-calls': 'off',\n 'no-setter-return': 'off',\n 'no-this-before-super': 'off',\n 'no-unreachable': 'off',\n 'no-unsafe-negation': 'off',\n 'no-with': 'off',\n 'no-var': 'error',\n 'prefer-const': 'error',\n 'prefer-rest-params': 'error',\n 'prefer-spread': 'error',\n // A value import of a type becomes a runtime import when Bun runs a decorated class's source\n // (emitDecoratorMetadata) and fails with `Export named 'X' not found`. `import('pkg').T` type\n // annotations stay allowed: they are type-only by construction, and type an optional peer.\n 'typescript/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n fixStyle: 'inline-type-imports',\n disallowTypeAnnotations: false,\n },\n ],\n },\n },\n {\n files: JS_TS_FILES,\n rules: {\n 'no-constant-condition': 'off',\n 'prefer-const': 'error',\n 'no-var': 'error',\n curly: ['error', 'all'],\n [NoRestrictedImportsRule.NAME]: NoRestrictedImportsRule.build(),\n 'typescript/no-unsafe-function-type': 'off',\n 'typescript/no-this-alias': 'off',\n 'typescript/no-empty-object-type': 'off',\n },\n },\n ],\n};\n\n/** Options of `OxlintConfigs.create`. */\nexport interface IOxlintPresetOptions {\n /**\n * Also allow `||` / `||=` where the left side is a number, so `limit || 20` passes: `0` falls\n * back on purpose. A string is allowed by the base already. Left off, the base catches a real `0`\n * swallowed by `||`.\n *\n * @default false\n */\n lenientFallback?: boolean;\n /**\n * Project paths to skip - generated files, vendored code - as in `--ignore-pattern`: `src/gen/**`.\n * Every rule is turned off for them (oxlint cannot ignore a project path from `.configs/`).\n * Share the list with ESLint through `LintIgnore`.\n *\n * @default []\n */\n ignore?: string[];\n}\n\n/**\n * Builds `oxlintConfigs` with options. Without any it returns the base preset unchanged.\n *\n * ```ts\n * // .configs/lints/oxlint.config.mts\n * import { defineConfig } from 'oxlint';\n * import { OxlintConfigs } from '@venizia/dev-configs/linters/oxlint';\n *\n * export default defineConfig(OxlintConfigs.create({ lenientFallback: true }));\n * ```\n */\nexport class OxlintConfigs {\n static create(opts: IOxlintPresetOptions = {}): OxlintConfig {\n const config: OxlintConfig = opts.lenientFallback\n ? {\n ...oxlintConfigs,\n rules: {\n ...oxlintConfigs.rules,\n [PreferNullishCoalescingRule.NAME]: PreferNullishCoalescingRule.build({\n ignorePrimitives: { string: true, number: true },\n }),\n },\n }\n : oxlintConfigs;\n\n return LintIgnore.oxlint({ config, patterns: opts.ignore ?? [] });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/dev-configs",
|
|
3
|
-
"version": "0.4.8-
|
|
3
|
+
"version": "0.4.8-4",
|
|
4
4
|
"description": "Shareable development configurations for TypeScript projects: oxlint presets with per-rule builders, the ESLint naming-convention rule, the legacy ESLint flat config, and TypeScript compiler options with critical decorator support (experimentalDecorators, emitDecoratorMetadata, useDefineForClassFields). Single source of truth for consistent code style, type checking, and build settings across monorepo packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build-tools",
|