-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feat: add Perl language rules, skills, and update documentation #366
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
necipsunmaz
wants to merge
3
commits into
affaan-m:main
Choose a base branch
from
necipsunmaz:feat/perl-rules-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,798
−24
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Coding Style | ||
|
|
||
| > This file extends [common/coding-style.md](../common/coding-style.md) with Perl specific content. | ||
| ## Standards | ||
|
|
||
| - Always `use v5.36` (enables `strict`, `warnings`, `say`, subroutine signatures) | ||
| - Use subroutine signatures — never unpack `@_` manually | ||
| - Prefer `say` over `print` with explicit newlines | ||
|
|
||
| ## Immutability | ||
|
|
||
| - Use **Moo** with `is => 'ro'` and `Types::Standard` for all attributes | ||
| - Never use blessed hashrefs directly — always use Moo/Moose accessors | ||
| - **OO override note**: Moo `has` attributes with `builder` or `default` are acceptable for computed read-only values | ||
|
|
||
| ## Formatting | ||
|
|
||
| Use **perltidy** with these settings: | ||
|
|
||
| ``` | ||
| -i=4 # 4-space indent | ||
| -l=100 # 100 char line length | ||
| -ce # cuddled else | ||
| -bar # opening brace always right | ||
| ``` | ||
|
|
||
| ## Linting | ||
|
|
||
| Use **perlcritic** at severity 3 with themes: `core`, `pbp`, `security`. | ||
|
|
||
| ```bash | ||
| perlcritic --severity 3 --theme 'core || pbp || security' lib/ | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
| See skill: `perl-patterns` for comprehensive modern Perl idioms and best practices. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Hooks | ||
|
|
||
| > This file extends [common/hooks.md](../common/hooks.md) with Perl specific content. | ||
|
|
||
| ## PostToolUse Hooks | ||
|
|
||
| Configure in `~/.claude/settings.json`: | ||
|
|
||
| - **perltidy**: Auto-format `.pl` and `.pm` files after edit | ||
| - **perlcritic**: Run lint check after editing `.pm` files | ||
|
|
||
| ## Warnings | ||
|
|
||
| - Warn about `print` in non-script `.pm` files — use `say` or a logging module (e.g., `Log::Any`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| paths: | ||
| - "**/*.pl" | ||
| - "**/*.pm" | ||
| - "**/*.t" | ||
| - "**/*.psgi" | ||
| - "**/*.cgi" | ||
| --- | ||
| # Perl Patterns | ||
|
|
||
| > This file extends [common/patterns.md](../common/patterns.md) with Perl specific content. | ||
|
|
||
| ## Repository Pattern | ||
|
|
||
| Use **DBI** or **DBIx::Class** behind an interface: | ||
|
|
||
| ```perl | ||
| package MyApp::Repo::User; | ||
| use Moo; | ||
|
|
||
| has dbh => (is => 'ro', required => 1); | ||
|
|
||
| sub find_by_id ($self, $id) { | ||
| my $sth = $self->dbh->prepare('SELECT * FROM users WHERE id = ?'); | ||
| $sth->execute($id); | ||
| return $sth->fetchrow_hashref; | ||
| } | ||
| ``` | ||
|
|
||
| ## DTOs / Value Objects | ||
|
|
||
| Use **Moo** classes with **Types::Standard** (equivalent to Python dataclasses): | ||
|
|
||
| ```perl | ||
| package MyApp::DTO::User; | ||
| use Moo; | ||
| use Types::Standard qw(Str Int); | ||
|
|
||
| has name => (is => 'ro', isa => Str, required => 1); | ||
| has email => (is => 'ro', isa => Str, required => 1); | ||
| has age => (is => 'ro', isa => Int); | ||
| ``` | ||
|
|
||
| ## Resource Management | ||
|
|
||
| - Always use **three-arg open** with `autodie` | ||
| - Use **Path::Tiny** for file operations | ||
|
|
||
| ```perl | ||
| use autodie; | ||
| use Path::Tiny; | ||
|
|
||
| my $content = path('config.json')->slurp_utf8; | ||
| ``` | ||
|
|
||
| ## Module Interface | ||
|
|
||
| Use `Exporter 'import'` with `@EXPORT_OK` — never `@EXPORT`: | ||
|
|
||
| ```perl | ||
| use Exporter 'import'; | ||
| our @EXPORT_OK = qw(parse_config validate_input); | ||
| ``` | ||
|
|
||
| ## Dependency Management | ||
|
|
||
| Use **cpanfile** + **carton** for reproducible installs: | ||
|
|
||
| ```bash | ||
| carton install | ||
| carton exec prove -lr t/ | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
| See skill: `perl-patterns` for comprehensive modern Perl patterns and idioms. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.