Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement ESLint rules based on TypeScript/JavaScript patterns analysis with test exceptions and update Copilot instructions#290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/analyze-eslint-rules

Conversation

Copy link

CopilotAI commentedOct 25, 2025
edited
Loading

Analysis: TypeScript/JavaScript Code Patterns for ESLint Rules

This analysis examines the React Native Node-API codebase to identify consistent patterns that should be codified in ESLint rules.

Progress Checklist

  • Explore repository structure and current ESLint configuration
  • Analyze TypeScript/JavaScript files across all packages
  • Identify consistent code patterns and conventions
  • Document findings for ESLint rule recommendations
  • Present proposed ESLint rules to user for approval
  • Update Copilot instructions with code style findings
  • Implement approved ESLint rules (excluding prefer-readonly-parameter-types)
  • Address feedback on Copilot instructions content
  • Add test file exception for arrow function rule
  • Fix violations found by new rules (waiting as requested)
  • Verify build and tests still pass after fixes

Current ESLint Configuration

The project now uses ESLint 9 with flat config format and includes:

  • @eslint/js recommended rules
  • typescript-eslint recommended type-checked rules
  • eslint-config-prettier for Prettier integration
  • Custom rule for@typescript-eslint/no-floating-promises with Node.js test function exceptions
  • NEW: 18 additional rules based on identified patterns
  • NEW: Test file exception forprefer-arrow-callback rule

Implementation Summary

Updated Copilot Instructions with key code style patterns:

  • Import organization (Node.js protocol, grouping)
  • Type definition preferences (type overinterface)
  • Immutable data patterns (as const assertions)
  • Function style conventions (with test exception noted)
  • Error handling preferences

Added ESLint Rules (18 total):

  • Import Organization:import/order,n/prefer-node-protocol,consistent-type-imports
  • Type Consistency:consistent-type-definitions,prefer-as-const
  • Immutable Patterns:prefer-readonly (excludedprefer-readonly-parameter-types per feedback)
  • Error Standards:prefer-promise-reject-errors,only-throw-error
  • Function Style:promise-function-async,require-await,prefer-arrow-callback (disabled for test files)
  • Console Control:no-console (warn level, allows error/warn)
  • Unused Code:no-unused-vars (with underscore prefix ignoring),unused-imports/no-unused-imports
  • Strict Typing:strict-boolean-expressions (warn),no-unnecessary-condition (warn),prefer-nullish-coalescing,prefer-optional-chain

Test File Handling:

  • Added specific configuration for**/*.test.ts and**/*.spec.ts files
  • Disabledprefer-arrow-callback rule for test files to allow regular functions indescribe() andit() callbacks
  • Updated Copilot instructions to document this exception

Configuration is validated and working. Test files correctly exempt from arrow function rule while maintaining enforcement for regular source files. Found 864 violations across codebase as expected - ready for systematic fixing when approved.

Original prompt

I want you to analyse the Typescript and JavaScript parts of the codebase to find patterns that is used but not yet codified in the eslint rules. I want you to first present the rules you want to enable and once I give the go-ahead I want you to enable the rules we agree on and fix any outstanding violations.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

CopilotAI self-assigned thisOct 25, 2025
CopilotAI changed the title[WIP] Analyze patterns in Typescript and JavaScript codebaseAnalyze TypeScript/JavaScript patterns for ESLint rule codificationOct 25, 2025
Copilot finished work on behalf ofkraenhansenOctober 25, 2025 13:00
@kraenhansen
Copy link
Collaborator

kraenhansen commentedOct 25, 2025
edited
Loading

@copilot I'm a bit concerned that prefer-readonly-parameter-types would raise too many issues. In general I agree I'm using functional programming a lot, but I don't think I'm actually enforcing this with types at the moment. Also, I like your key findings. Can you start by amending the Copilot instructions to capture these?

@kraenhansen
Copy link
Collaborator

@copilot go ahead and make the changes to the eslint config. I want you to wait with fixing the issues.

…Copilot instructionsCo-authored-by: kraenhansen <1243959+kraenhansen@users.noreply.github.com>
Copy link
Author

CopilotAI commentedOct 26, 2025
edited
Loading

@copilot go ahead and make the changes to the eslint config. I want you to wait with fixing the issues.

ESLint configuration updated with 18 new rules based on the analyzed patterns. The configuration is validated and working - found 901 violations as expected. Ready for systematic fixing when you give the go-ahead. Commitbff493c

@copilot I'm a bit concerned that prefer-readonly-parameter-types would raise too many issues. In general I agree I'm using functional programming a lot, but I don't think I'm actually enforcing this ...

I've excludedprefer-readonly-parameter-types from the implementation and updated the Copilot instructions to capture the key code style findings including import organization, type preferences, immutable data patterns, function conventions, and error handling approaches. Commitbff493c

CopilotAI changed the titleAnalyze TypeScript/JavaScript patterns for ESLint rule codificationImplement ESLint rules based on TypeScript/JavaScript patterns analysis and update Copilot instructionsOct 26, 2025
Copilot finished work on behalf ofkraenhansenOctober 26, 2025 22:06
- Use structured error handling with custom error types when needed

**Immutable Data Patterns**:
- Use`as const satisfies Record<string, z.ZodType>` for Zod schemas
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot remove this.

Suggested change
- Use `as const satisfies Record<string, z.ZodType>` for Zod schemas

Copy link
Author

Choose a reason for hiding this comment

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

Removed the readonly data structures line from the Copilot instructions. Commitb7cb726

…edbackCo-authored-by: kraenhansen <1243959+kraenhansen@users.noreply.github.com>
Copilot finished work on behalf ofkraenhansenOctober 26, 2025 22:19
**Function Style**:
- Prefer`export function` over`export const fn =`
- Use async/await consistently for asynchronous operations
- Prefer arrow functions for callbacks and inline functions
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot an exception to this rule is in tests where the callback passed todescribe andit are functions. Please update the instruction and eslint rule to reflect that (limiting the rule to hit only non*.test.ts files would be okay).

Copy link
Author

Choose a reason for hiding this comment

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

Added exception for test files to theprefer-arrow-callback rule and updated Copilot instructions to document thatdescribe andit functions use regular functions in tests. The rule now excludes**/*.test.ts and**/*.spec.ts files. Commitc13a5d1

…ilot instructionsCo-authored-by: kraenhansen <1243959+kraenhansen@users.noreply.github.com>
CopilotAI changed the titleImplement ESLint rules based on TypeScript/JavaScript patterns analysis and update Copilot instructionsImplement ESLint rules based on TypeScript/JavaScript patterns analysis with test exceptions and update Copilot instructionsOct 26, 2025
Copilot finished work on behalf ofkraenhansenOctober 26, 2025 22:29
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kraenhansenkraenhansenAwaiting requested review from kraenhansen

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@kraenhansen

[8]ページ先頭

©2009-2025 Movatter.jp