Skip to content
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

Disable explicit member accessibility for constructors #158

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Disable `@typescript-eslint/explicit-member-accessibility` for constructors",
"packageName": "@ni/eslint-config-typescript",
"email": "[email protected]",
"dependentChangeType": "minor"
}
7 changes: 5 additions & 2 deletions packages/eslint-config-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ module.exports = {
/*
Requiring an accessibility modifier helps when creating classes to ensure the
accessibility of a class member is intentionally decided and not relying on
the default of public accessibility.
the default of public accessibility. Constructors are omitted because they are
almost always public.
*/
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/explicit-member-accessibility': ['error',
{ accessibility: 'explicit', overrides: { constructors: 'off' } }
],

/*
All interface members should be terminated with a semicolon including single line
Expand Down
4 changes: 4 additions & 0 deletions tests/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
export class NI {
private _awesomeLevel = 1;

constructor() {
this._awesomeLevel = 11;
}

public get awesome(): boolean {
return this._awesomeLevel > 0;
}
Expand Down