Skip to content

feat: add disallow-references rule#6

Merged
StyleShit merged 13 commits intoStyleShit:mainfrom
IshayMaya:feat/no-assign-ref
Apr 29, 2025
Merged

feat: add disallow-references rule#6
StyleShit merged 13 commits intoStyleShit:mainfrom
IshayMaya:feat/no-assign-ref

Conversation

@IshayMaya
Copy link
Copy Markdown
Collaborator

@IshayMaya IshayMaya commented Apr 25, 2025

Closes #11

@IshayMaya IshayMaya closed this Apr 25, 2025
@IshayMaya IshayMaya reopened this Apr 25, 2025
@StyleShit StyleShit changed the title feat: add no-assign-ref rule feat: add no-references rule Apr 27, 2025
@StyleShit StyleShit changed the title feat: add no-references rule feat: add disallow-references rule Apr 27, 2025
README.md Outdated
| `php/eqeqeq` | Require the use of `===` and `!==` | | |
| `php/no-array-keyword` | Disallow the use of the array keyword | 🔧 | |
| `php/require-visibility` | Require visibility for class methods and properties | | 💡 |
| `php/disallow-references` | Disallow assigning by reference | | 💡 |
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

A-Z

src/index.ts Outdated

import { eqeqeq } from './rules/eqeqeq';
import { noArrayKeyword } from './rules/no-array-keyword';
import { disallowReferences } from './rules/disallow-references';
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

A-Z? 🫣

) {
context.report({
node,
messageId: 'noAssignRef',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
messageId: 'noAssignRef',
messageId: 'disallowReferences',

messageId: 'noAssignRef',
suggest: [
{
desc: 'Remove reference assignment',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

use a message id instead, and change the text ("remove reference syntax"?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

"Remove the reference operator (&)."


return fixer.replaceText(
node,
nodeText.replace(/&/g, ''),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
nodeText.replace(/&/g, ''),
nodeText.replace(/^&/, ''),

just for safety

Comment on lines +12 to +15
description: 'Disallow assigning by reference',
},
messages: {
noAssignRef: 'Assigning by reference is not allowed.',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

change texts


export const disallowReferences = createRule<MessageIds, Options>({
meta: {
type: 'layout',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
type: 'layout',
type: 'suggestion',

(we need to fix others as well)

Comment on lines +17 to +21
valid: [
'<?php $a = [];',
'<?php function foo() {}',
'<?php function foo($var) {}',
],
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

add all the valid variations of the invalid ones

endColumn: 37,
suggestions: [
{
desc: 'Remove the reference operator (&).',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

use messageId

README.md Outdated
| `php/eqeqeq` | Require the use of `===` and `!==` | | |
| `php/no-array-keyword` | Disallow the use of the array keyword | 🔧 | |
| `php/require-visibility` | Require visibility for class methods and properties | | 💡 |
| `php/disallow-references` | Disallow assigning by reference | | 💡 |
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

update text

Copy link
Copy Markdown
Owner

@StyleShit StyleShit left a comment

Choose a reason for hiding this comment

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

🔥🔥🔥

@StyleShit StyleShit merged commit 58e504c into StyleShit:main Apr 29, 2025
2 checks passed
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.

Add disallow-references rule

2 participants