Skip to content

feat(config): supports importing rules from http url#7

Merged
johnsoncodehk merged 4 commits into
masterfrom
http-import
Jun 8, 2024
Merged

feat(config): supports importing rules from http url#7
johnsoncodehk merged 4 commits into
masterfrom
http-import

Conversation

@johnsoncodehk
Copy link
Copy Markdown
Owner

Supports directly using HTTP URL to import single or multiple rules without adding dependencies in package.json.

import { defineConfig } from '@tsslint/config';

export default defineConfig({
	rules: {
		'no-console': (await import('https://.../noConsoleRule.ts')).create(),
	},
});

@johnsoncodehk johnsoncodehk merged commit 62e20f8 into master Jun 8, 2024
@johnsoncodehk johnsoncodehk deleted the http-import branch June 8, 2024 17:46
johnsoncodehk added a commit that referenced this pull request May 2, 2026
Hardens the test suite against the bug class fixed earlier in this
PR (JSXAttribute.parent corruption via phantom TSJsxAttributes).
Master's tests had three blind spots:

  1. lazy-estree.test's `compare()` walks tree TOP-DOWN through child
     getters, where parent is set correctly even on master. Bottom-up
     `materialise(tsNode)` (what tsScanTraverse does on selector match)
     was never exercised. The function also explicitly skips the
     `parent` field — so even top-down parent-chain corruption would
     not have failed parity.
  2. compat-pipeline's JSXAttribute listener pushed `attr:${n.name}`
     events but never read `n.parent`, leaving the listener-API parent
     contract unverified.
  3. Nothing checked the invariant "no node has a 'TS<KindName>' type
     for kinds typescript-estree elides" — the property the
     TSJsxAttributes regression directly violated.

Three new test blocks address each:

  Bottom-up parity sweep (lazy-estree.test): 9 JSX-attribute fixtures
  (self-closing, non-self-closing, spread, sibling attrs, multi-attr
  mixed, fragment, nested attr value, deeply nested), each walks every
  TS node, runs `lazy.materialise(tsNode, ctx)`, and compares the
  resulting type / parent.type / parent.parent.type against eager's
  `astMaps.tsNodeToESTreeNodeMap` lookup. Eager parents are stitched
  ourselves (typescript-estree's astConverter doesn't set parent —
  ESLint's SourceCode does that downstream). 117 type asserts + 108
  parent asserts on the fix branch; 7 unique mismatches on master.

  Phantom-types invariant (lazy-estree.test): 5 comprehensive fixtures
  (jsx-attrs-everything, ts-everything, imports-everything, patterns-
  everything, jsx-fragment-mix), each walks via visitor-keys and ALSO
  bottom-up materialises every TS node that has an eager counterpart.
  Asserts no produced type starts with 'TS' AND isn't in typescript-
  estree's published TS-* type list. The published list is hard-coded
  inline (~75 entries) so the test fails immediately if a future
  PR-added GenericTSNode fallback emits a name not in eager's spec.

  JSX listener parent assertion (compat-pipeline): test #7's
  JSXAttribute / JSXSpreadAttribute listeners now also assert
  `parents[0] === 'JSXOpeningElement'` — the contract any
  jsx-a11y / react/jsx-* rule relies on. The contract is correct in
  spec; whether each listener path independently fails on master
  depends on whether sibling listeners pre-warm the cache top-down,
  but the assert still locks the contract from inside the actual
  ESLint listener API surface.

Out of scope (real but unrelated impedance with eager that the broad
sweep also surfaces — left as separate follow-ups):
  - export wrapper identity (lazy maps the TS node to ExportNamed/
    DefaultWrapper, eager maps to the inner declaration)
  - chain-expression wrapping for `a?.b?.c`
  - destructuring with defaults
  - CatchClause param lifted from ts.VariableDeclaration shim
  - TSStringKeyword / TSVoidKeyword direct-on-Signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant