Skip to content

feat(eslint-config): add opt-in strict rule set - #97

Merged
amondnet merged 24 commits into
mainfrom
tracks/opt-in-strict-rules-20261121
Nov 22, 2026
Merged

amondnet merged 24 commits into
mainfrom
tracks/opt-in-strict-rules-20261121

Conversation

@amondnet

@amondnet amondnet commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a strict option to @pleaseai/eslint-config that turns on non-type-aware rules adopted from cloudflare/oxlint-config: no-promise-executor-return, ts/no-confusing-non-null-assertion, unicorn/prefer-set-has, import/no-self-import, and strict eqeqeq ('always'). The option is off by default, and this repository turns it on for itself.

  • Track: opt-in-strict-rules-20261121 (spec · plan)
  • import/no-self-import comes from eslint-plugin-import-x in the default mode and from eslint-plugin-import with canonicalPluginNames. Both modes resolve TypeScript sources through eslint-import-resolver-typescript, so extensionless, .js, and tsconfig paths self-imports are reported. eslint-plugin-import-x and eslint-import-resolver-typescript are regular dependencies, loaded only when strict is on.
  • Consumer overrides win over strict: per-group overrides are re-applied after the strict block on the files and option group antfu applied them to, and a consumer config that sets a resolver key the active import plugin reads replaces the strict resolver fallback.
  • packages/cli replaces 86 loose == null comparisons with strict checks that keep each comparison's meaning.

Closes #96

Checklist

  • PR title follows Conventional Commits
  • Packages build (bun run build)
  • Lint/format pass (bun run lint)
  • Documentation updated if behavior changed (both READMEs, en/ko eslint-config/advanced.mdx)
  • No breaking change (strict is opt-in, off by default)

Verification Checklist

  • bun run build and bun run test pass (root, HEAD de16021: ast-grep-config 3, cli 325, eslint-config 386 pass, 0 fail)
  • mise exec -- bun run lint passes at the root with strict: true
  • bun run typecheck and bun run lint:docs pass in apps/docs (0 errors; 22 files lint clean)
  • Every AC from AC-001 to AC-012 maps to a T001 or T002 test, or to T003's lint run (spec compliance gate in /please:review; note: the AC-012 override test does not also assert that import/no-self-import still reports)

Summary by cubic

Adds an opt-in strict rule set to @pleaseai/eslint-config (closes #96), ships eslint-plugin-import-x and eslint-import-resolver-typescript as dependencies, and turns strict: true on in this repository.

  • strict: true enables eqeqeq ('always'), no-promise-executor-return, unicorn/prefer-set-has, ts/no-confusing-non-null-assertion, and import/no-self-import at error level on JS and TS files outside Markdown code blocks.
  • Consumer overrides through antfu's per-plugin options (including deprecated top-level ones) and a consumer import resolver beat strict; the no-self-import merge is cached per plugin object, so reusing the same plugin in a user config no longer fails. When detecting a consumer resolver, a non-object settings value is skipped, and ESLint rejects a null settings value under strict.
  • A resolver reports TypeScript self-imports in both plugin modes — extensionless, .js, and tsconfig paths alias imports. canonicalPluginNames still needs the optional eslint-plugin-import peer.
  • Replaces 86 loose null comparisons in packages/cli with strict checks chosen from each operand's type, makes readPackageJson reject package.json content that is not a JSON object (shared with antislop via isJsonObject, narrowed to the object type), and excludes the self-importing test fixtures from linting.
  • Sets up the .please/ workspace scaffolding and documents the option in both READMEs and the en/ko documentation pages.

Written for commit 8c9a23f. Summary will update on new commits.

Turn on auto-fix

@amondnet amondnet changed the title docs(track): add spec and plan for opt-in-strict-rules-20261121 feat(eslint-config): add opt-in strict rule set Nov 21, 2026
Set up the please workspace (.please/, docs/knowledge, docs/adr index)
and add the track for an opt-in strict rule set.

Refs #96
@amondnet
amondnet force-pushed the tracks/opt-in-strict-rules-20261121 branch from c3f8829 to ee4aa49 Compare November 21, 2026 03:22
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying code-style with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8c9a23f
Status: ✅  Deploy successful!
Preview URL: https://3790e565.code-style.pages.dev
Branch Preview URL: https://tracks-opt-in-strict-rules-2.code-style.pages.dev

View logs

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive workspace configuration, documentation, and planning files for the @pleaseai/code-style project. It establishes a workspace index, configuration settings, a new implementation track for an opt-in strict rule set, and extensive domain knowledge documents covering product guidelines, tech stack, and workflows. The reviewer identified a minor typo in docs/knowledge/product.md where the path for @pleaseai/prettier-config was misspelled as packages/perttier-config instead of packages/prettier-config.

Comment thread docs/knowledge/product.md Resolved
@codacy-production

codacy-production Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 7 high

Alerts:
⚠ 7 issues (≤ 0 issues of at least minor severity)

Results:
7 new issues

Category Results
ErrorProne 6 high
Security 1 high

View in Codacy

🟢 Metrics 130 complexity · 0 duplication

Metric Results
Complexity 130
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Tag each plan task with the spec requirements it covers.

Refs #96
- T001: strict option adds no-promise-executor-return, eqeqeq 'always',
  unicorn/prefer-set-has and ts/no-confusing-non-null-assertion
- Tests: passed

Refs #96

[/please:implement]
- T002: merge eslint-plugin-import-x's no-self-import into antfu's import
  plugin (default mode); canonical mode uses eslint-plugin-import natively
- Tests: passed

Refs #96

[/please:implement]
- T003: enable strict in eslint.config.ts and replace 86 loose null
  comparisons with strict checks chosen from the operand type
- Tests: passed

Refs #96

[/please:implement]
- T004: add Strict Rules sections to both READMEs and the en/ko advanced
  docs pages, polish the strict JSDoc, list eslint-plugin-import-x in
  tech-stack.md
- Tests: passed

Refs #96

[/please:implement]
@amondnet amondnet mentioned this pull request Nov 21, 2026
9 of 13 tasks
@socket-security

socket-security Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedeslint-import-resolver-typescript@​4.4.59910010084100
Addedeslint-plugin-import-x@​4.18.19810010088100

View full report

…ort plugin object

strict now leaves out any rule the user set through antfu's per-plugin
override options (javascript, typescript, unicorn, imports, and the
deprecated top-level overrides), so FR-7 holds for those paths too.

The no-self-import merge is cached per original plugin, so a user config
that registers the same import plugin object no longer fails with
"Cannot redefine plugin".
…elf-import

import-x's default resolver skips .ts files, so extensionless and .js
self-imports in TypeScript went unreported. Under strict in the default
plugin mode, a pleaseai/strict/import-resolver config now gives import-x
a node resolver with TypeScript extensions and .js -> .ts aliases. It sits
before the user configs, so a consumer's own resolver settings still win.
…uginNames

eslint-plugin-import's default node resolver skips .ts files and has no
.js -> .ts alias, so strict import/no-self-import missed TypeScript
self-imports in canonical mode. Add eslint-import-resolver-typescript as
a dependency and point import/resolver at this package's own copy by
absolute path, since eslint-plugin-import resolves resolvers relative to
the linted file. The TypeScript self-import tests now run in both modes.
…overs

antfu applies typescript, overridesTypeAware and test overrides only to
its own file globs, so dropping those rules from the whole strict block
also turned them off for JS files, while test overrides lost to strict
in test files. Strict now drops only unscoped overrides (javascript,
unicorn, imports) and re-applies the scoped ones after its block, on the
same files antfu uses.
A hard-coded list of override groups kept missing groups (e18e, regexp,
stylistic, perfectionist, ...) and counted overrides of disabled groups.
The strict block no longer drops rules. Once configs resolve, every
antfu config before it that took one of the consumer's overrides for a
strict rule is re-applied right after it, on that config's own files, so
the override wins exactly where antfu applied it.
…ks in the default mode

The default plugin mode now gives import-x eslint-import-resolver-typescript's
createTypeScriptImportResolver, so a module that imports itself through a tsconfig
paths alias is reported in both plugin modes.
… fallback

The strict TypeScript resolver is dropped when a consumer config sets a resolver
for every file, and excludes the files a file-scoped consumer resolver covers.
…tive plugin reads

Only the resolver keys the active import plugin reads count as a consumer resolver,
and the files a consumer resolver config skips through its own ignores keep the
strict TypeScript fallback.
… one

Any config that sets a resolver key the active import plugin reads, including
import-x/resolve, now removes the strict TypeScript fallback for every file,
replacing the per-file scope narrowing. The docs note that canonicalPluginNames
still needs the optional peer eslint-plugin-import.
Merge the strict resolver config builders, cache the no-self-import merge in a
WeakMap and load only that rule from import-x, skip strictOverrides when nothing
needs re-applying, and share one lint helper across the strict tests.
@amondnet
amondnet marked this pull request as ready for review November 22, 2026 02:20

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Nov 22, 2026
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes appear safe to merge; no actionable new issue was found.

Summary

Adds an opt-in strict rule set and enables it in this repository.

  • Projects can opt into five stricter ESLint checks with strict: true.
  • The package reader rejects JSON that is not an object.
  • The CLI keeps the same checks with explicit null comparisons and set membership.
  • The repository gains a tracked .please workspace for project notes and workflows.

Reviews (5) · Last reviewed commit: "test(eslint-config): assert ESLint rejec..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

All reported issues were addressed across 65 files

Linked issue analysis

Linked issue: pleaseai/code-style#96: track: opt-in-strict-rules-20261121

Status Acceptance criteria Notes
✅ Keep strict rules opt-in and off by default The option defaults off, and the PR enables it explicitly in this repository’s ESLint config.
✅ Enable the five specified checks without type information The PR lists all five rules, and strict-rule tests cover the configuration and import-plugin modes.
✅ Allow consumers to override individual strict rules The PR re-applies consumer overrides after the strict block and describes tests for override behavior.
✅ Turn strict on here and resolve its findings The root config enables strict, and the diff replaces loose null comparisons and adjusts affected code.
⚠️ Document strict and record its first-run finding counts The README additions document the option, but the provided diff does not show strict finding counts.
Architecture diagram
sequenceDiagram
    participant User as Consumer Project
    participant Config as pleaseai() Config Builder
    participant Antfu as @antfu/eslint-config
    participant Strict as strict.ts Rules
    participant ImportX as eslint-plugin-import-x
    participant Resolver as eslint-import-resolver-typescript
    participant ESLint as ESLint Engine

    Note over User,ESLint: Config Resolution Phase
    
    User->>Config: pleaseai({ strict: true })
    Config->>Antfu: composer = antfu(options)
    Config->>Config: Check canonicalPluginNames flag
    
    alt Default mode (no canonicalPluginNames)
        Config->>Strict: strict({ importPlugin: 'import' })
        Strict-->>Config: strict rules config
        Config->>Antfu: insertBefore('antfu/disables/scripts', strictConfigs)
        Config->>Config: Schedule strictOverrides onResolved
        Config->>ImportX: Dynamic import no-self-import rule
        ImportX-->>Config: Rule object
        Config->>Antfu: replacePlugin('import', mergedPlugin)
        Config->>Resolver: createTypeScriptImportResolver()
        Resolver-->>Config: Resolver settings
        Config->>Antfu: insertBefore with resolver config
    else Canonical mode (canonicalPluginNames: true)
        Config->>Strict: strict({ importPlugin: 'import' })
        Strict-->>Config: strict rules config
        Config->>Antfu: insertBefore('antfu/disables/scripts', strictConfigs)
        Config->>Config: Resolve resolver path via createRequire
        Config->>Antfu: insertBefore with absolute resolver path
        Note over Config: eslint-plugin-import provides rule natively
    end

    Config-->>User: Resolved config array

    Note over User,ESLint: Linting Phase
    
    User->>ESLint: Lint files with resolved config
    ESLint->>ESLint: Apply strict rules to JS/TS files
    
    alt Consumer overrides exist
        ESLint->>Config: strictOverrides(configs, options)
        Config->>Config: Find rules with consumer overrides
        Config->>Config: Re-apply overrides after strict block
    end

    alt Resolver conflict detected
        Config->>Config: Check for consumer resolver settings
        alt Consumer sets resolver key
            Config->>Config: Remove strict resolver fallback
            Note over Config: Consumer's resolver owns all resolution
        else No consumer resolver
            Config->>Resolver: Resolve imports (extensionless, .js→.ts, paths aliases)
            Resolver-->>ESLint: Resolved module paths
        end
    end

    ESLint->>ImportX: Execute no-self-import rule
    ImportX->>Resolver: Resolve import specifiers
    Resolver-->>ImportX: Resolved paths
    ImportX-->>ESLint: Self-import findings

    alt Strict rule violations found
        ESLint-->>User: Error-level findings
    else All rules pass
        ESLint-->>User: Clean lint results
    end
Loading

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread docs/knowledge/workflow.md Resolved
Comment thread docs/knowledge/workflow.md Resolved
Comment thread docs/knowledge/product.md Resolved
- reject a package.json that is not a JSON object in readPackageJson,
  sharing the check with antislop through isJsonObject (resolves TD-002)
- assert import/no-self-import survives turning off another strict rule
- correct the track plan and spec to the shipped rule id and resolver,
  and tick the verified checklists
- fix stale knowledge docs (commit types, integration checks, strict
  feature, dead AGENTS.md links) and note the fixture exclusion in docs

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an opt-in strict rule set to @pleaseai/eslint-config based on cloudflare/oxlint-config, enabling rules such as no-promise-executor-return, strict eqeqeq, unicorn/prefer-set-has, ts/no-confusing-non-null-assertion, and import/no-self-import. The repository itself has been updated to use this strict configuration, resolving numerous loose equality checks. Feedback on the changes suggests refactoring the isJsonObject type guard in packages/cli/src/fs-utils.ts to use a generic named interface rather than asserting PackageJson directly, which improves type safety and avoids triggering the 'quality/no-known-value-widening' lint rule.

Comment thread packages/cli/src/fs-utils.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 12 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/src/fs-utils.ts Resolved
@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an opt-in strict rule set to @pleaseai/eslint-config based on cloudflare/oxlint-config, enabling rules like no-promise-executor-return, strict eqeqeq, unicorn/prefer-set-has, ts/no-confusing-non-null-assertion, and import/no-self-import. It integrates eslint-plugin-import-x and eslint-import-resolver-typescript to support self-import detection and TypeScript resolution. The codebase has been updated to resolve new strict lint findings, and comprehensive tests and documentation have been added. The review feedback highlights a potential runtime crash in setsResolver when a user-defined ESLint flat config contains a null or non-object settings property, and recommends adding defensive checks before using the in operator.

Comment thread packages/eslint-config/src/strict.ts Resolved
@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new opt-in strict rule set to @pleaseai/eslint-config, which enables stricter linting rules adopted from Cloudflare's oxlint configuration, including no-promise-executor-return, strict eqeqeq (disallowing loose null checks), unicorn/prefer-set-has, ts/no-confusing-non-null-assertion, and import/no-self-import. To support these rules, eslint-plugin-import-x and eslint-import-resolver-typescript have been added as dependencies. Additionally, the repository's own codebase has been updated to comply with these strict rules by refactoring loose null/undefined checks to strict comparisons, and comprehensive tests and documentation have been added. As there are no review comments provided, I have no further feedback to provide on this pull request.

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@gitar-bot

gitar-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

The opt-in strict rules and package.json validation change lint and CLI behavior; consumers may see new lint errors or rejection of malformed metadata.

Adds an opt-in strict rule set to @pleaseai/eslint-config that enables eqeqeq, no-promise-executor-return, unicorn/prefer-set-has, ts/no-confusing-non-null-assertion, and import/no-self-import, with consumer overrides taking precedence. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Important

Your trial ends in 5 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@amondnet
amondnet merged commit b8c65b3 into main Nov 22, 2026
13 of 14 checks passed
@amondnet
amondnet deleted the tracks/opt-in-strict-rules-20261121 branch November 22, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gitar-approved Added by Gitar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

track: opt-in-strict-rules-20261121

1 participant