@wp-typia/ttsc-lint-plugin-wp
v0.5.0
Published
WordPress lint rule and preset compatibility for @ttsc/lint
Downloads
1,051
Readme
@wp-typia/ttsc-lint-plugin-wp
WordPress-specific lint rules and preset compatibility for @ttsc/lint.
This package ports WordPress rules to native TypeScript-Go contributors and
maps the upstream @wordpress/eslint-plugin surface to rules already provided
by @ttsc/lint. It does not depend on wp-typia, typia, or
@wp-typia/project-tools at runtime.
Install
npm install --save-dev \
@wp-typia/ttsc-lint-plugin-wp \
@ttsc/lint \
ttsc \
typescriptAdd lint.config.mts in CommonJS projects so the ESM contributor is loaded
unambiguously (lint.config.ts also works in ESM projects):
import type { ITtscLintConfig } from '@ttsc/lint';
import { configs } from '@wp-typia/ttsc-lint-plugin-wp';
export default {
...configs.wpScriptsRecommended,
rules: {
'wordpress/i18n-text-domain': ['error', { allowedTextDomain: 'my-plugin' }],
},
} satisfies ITtscLintConfig;The compiled preset is a static package-owned extends chain. It folds
consecutive entries with the same file scope while retaining effective
upstream ordering, selectors, ignores, severities, and supported options
without loading ESLint in consumer projects. Unsupported and external-runner
rules are left out and remain visible in the compatibility manifest.
When the current @ttsc/lint baseline implements a rule but not an upstream
option payload, the compiled config keeps the severity and records the pair in
compiledPresets.recommended.optionDowngrades. Consumers never receive an
option tuple that the native host would silently ignore or reject.
Rules that the native engine exposes but cannot yet execute with equivalent
behavior are omitted and recorded in
compiledPresets.recommended.behaviorDowngrades. The current baseline omits
no-shadow because @ttsc/lint panics on catch clauses, and omits
jsx-a11y/click-events-have-key-events plus
jsx-a11y/no-static-element-interactions because imported WordPress
components are misclassified as native DOM elements. It also omits
jsx-a11y/role-supports-aria-props because the native baseline rejects valid
aria-valuemin usage on role="progressbar". Each rule returns to the compiled
preset only after its engine or semantic parity regression passes.
Use ttsc check --noEmit as the combined TypeScript and lint gate, or ttsc
fix to apply available lint and format fixes. ttsc intentionally has no
lint-only command; consumers should expose the combined gate under a clear
script name such as check:code instead of retaining a misleading lint-only
alias.
For JavaScript and JSX coverage, set allowJs: true and include the relevant
.js, .jsx, .cjs, and .mjs paths in the TypeScript project used by the
command. Stylelint and non-code formatting remain separate concerns.
Native rules
wordpress/components-no-missing-40px-size-propwordpress/components-no-unsafe-button-disabledwordpress/data-no-store-string-literalswordpress/dependency-groupwordpress/i18n-ellipsiswordpress/i18n-hyphenated-rangewordpress/i18n-no-collapsible-whitespacewordpress/i18n-no-flanking-whitespacewordpress/i18n-no-placeholders-onlywordpress/i18n-no-variableswordpress/i18n-text-domainwordpress/i18n-translator-commentswordpress/no-base-control-with-label-without-idwordpress/no-dom-globals-in-constructorwordpress/no-dom-globals-in-module-scopewordpress/no-dom-globals-in-react-cc-renderwordpress/no-dom-globals-in-react-fcwordpress/no-ds-tokenswordpress/no-global-active-elementwordpress/no-global-get-selectionwordpress/no-i18n-in-savewordpress/no-non-module-stylesheet-importswordpress/no-setting-ds-tokenswordpress/no-unguarded-get-range-atwordpress/no-unknown-ds-tokenswordpress/no-unmerged-classnamewordpress/no-unsafe-render-orderwordpress/no-unsafe-wp-apiswordpress/no-unused-vars-before-returnwordpress/no-wp-process-envwordpress/react-no-unsafe-timeoutwordpress/use-import-aswordpress/use-recommended-componentswordpress/valid-sprintfwordpress/wp-global-usage
The two components-* rules accept the upstream checkLocalImports boolean
to also track relative default imports. i18n-text-domain accepts the upstream
allowedTextDomain string or string
array. no-unsafe-wp-apis accepts a map from an @wordpress/* package to the
unstable or experimental named imports allowed from that package.
no-unsafe-render-order accepts checkLocalImports to include tracked
components imported from relative paths. no-unused-vars-before-return
accepts an excludePattern for call names that should not be treated as
expensive initializers. The pattern uses Go RE2 syntax; JavaScript-only
lookaheads, lookbehinds, and backreferences are not supported.
The no-dom-globals-* rules embed the browser-minus-node global list from
globals 16.5.0, the revision satisfying the globals@^16.0.0 dependency that
@wordpress/eslint-plugin 25.8.0 declares. The parity harness installs the
same pinned revision for its ESLint oracle and verifies the generated Go data
remains byte-equivalent, so the repository's own transitive globals copy can
never skew which identifiers the two engines treat as DOM-only globals. The
upstream rules are not part of any WordPress preset, so the compiled presets
are unchanged; enable the rules individually when SSR safety is required.
The Design System token rules embed the 167-token list from
@wordpress/theme 1.1.0 used by the pinned ESLint oracle. The parity harness
verifies that the embedded ordered list remains exactly equivalent while the
published contributor retains no runtime dependency on the theme package.
The upstream react-hooks/rules-of-hooks and
react-hooks/exhaustive-deps identifiers map to the native
react/rules-of-hooks and react/exhaustive-deps rules. The WordPress
additionalHooks option for useSelect and useSuspenseSelect is recorded as
an option downgrade because the current native rule accepts severity only;
standard React dependency hooks remain enabled.
Presets and compatibility
The exported configs.custom, configs.i18n, and configs.recommended
objects enable the native rules currently implemented by this package.
configs.i18n has full parity with the WordPress-owned rules in the upstream
i18n preset. All 19 WordPress-owned rules enabled by the upstream
recommended preset now have native contributors. The broader custom and
recommended preset labels remain partial because they also contain scoped
overrides and generic ecosystem rules; presetCompatibility does not claim
that those wider contracts are complete.
configs.wpScriptsRecommended compiles the supported portion of the full
upstream recommended entry chain. It is also marked partial until every
error-level rule has a documented contributor, builtin, compiler, formatter,
or intentional replacement.
The published compatibility.json export inventories the 35 WordPress-owned
rules and every rule enabled or disabled across the 13 upstream presets in
@wordpress/eslint-plugin 25.8.0. Each rule is classified as:
builtin: the same rule exists in@ttsc/lint;mapped: a namespace translation reaches an@ttsc/lintrule;contributor: this package provides a native Go rule;runner: an external formatter such as Prettier owns the behavior;unsupported: parity work remains.
import { compatibilityManifest } from '@wp-typia/ttsc-lint-plugin-wp';The manifest pins the upstream package version and npm integrity. Parity tests
download that exact tarball plus its pinned @wordpress/theme token source,
verify both SHA-512 integrities, run the real ESLint rules as the oracle, and
compare their diagnostics with a linked ttsc contributor host. Unsafe
upstream fix behavior is intentionally not reproduced: native fixes preserve
template delimiters, non-range hyphens, concatenation separators, and quote
escaping. Dedicated regressions pin those safety guarantees.
Contributor boundary
The package ships Go rule sources under rules/ without a contributor-owned
go.mod. @ttsc/lint copies and links those sources into its own host module,
which is the upstream contributor contract. The wordpress namespace and Go
package name must remain aligned.
Rules are based on behavior from @wordpress/eslint-plugin 25.8.0 and are
distributed under GPL-2.0-or-later. WordPress and the WordPress logos are
trademarks of the WordPress Foundation; this compatibility package is not an
official WordPress Foundation package.
