PageSourceSearch

https://typescript-eslint.io/assets/js/8d05d3b9.9c60a241.js

js typescript-eslint.io collected 2026-10-02 02:15:52 UTC 29,128 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["2095"],{12761(e,i,n){n.r(i),n.d(i,{metadata:()=>s,default:()=>p,frontMatter:()=>l,contentTitle:()=>c,toc:()=>u,assets:()=>d});var s=JSON.parse('{"id":"explicit-member-accessibility","title":"explicit-member-accessibility","description":"Require explicit accessibility modifiers on class properties and methods.","source":"@site/../eslint-plugin/docs/rules/explicit-member-accessibility.mdx","sourceDirName":".","slug":"/explicit-member-accessibility","permalink":"/rules/explicit-member-accessibility","draft":false,"unlisted":false,"editUrl":"https://github.com/typescript-eslint/typescript-eslint/edit/main/packages/website/../eslint-plugin/docs/rules/explicit-member-accessibility.mdx","tags":[],"version":"current","frontMatter":{"description":"Require explicit accessibility modifiers on class properties and methods.","image":"/img/og/rules/explicit-member-accessibility.png"},"sidebar":"rulesSidebar","previous":{"title":"explicit-function-return-type","permalink":"/rules/explicit-function-return-type"},"next":{"title":"explicit-module-boundary-types","permalink":"/rules/explicit-module-boundary-types"}}'),t=n(65723),r=n(7143),o=n(70503),a=n(46742);let l={description:"Require explicit accessibility modifiers on class properties and methods.",image:"/img/og/rules/explicit-member-accessibility.png"},c,d={},u=[{value:"Examples",id:"examples",level:2},{value:"Options",id:"options",level:2},{value:"Configuring in a mixed JS/TS codebase",id:"configuring-in-a-mixed-jsts-codebase",level:3},{value:"<code>accessibility</code>",id:"accessibility",level:3},{value:"<code>overrides</code>",id:"overrides",level:3},{value:"Disallow the use of public on a given member",id:"disallow-the-use-of-public-on-a-given-member",level:4},{value:"Require explicit accessibility for a given member",id:"require-explicit-accessibility-for-a-given-member",level:4},{value:"Disable any checks on given member type",id:"disable-any-checks-on-given-member-type",level:4},{value:"<code>ignoredMethodNames</code>",id:"ignoredmethodnames",level:3},{value:"When Not To Use It",id:"when-not-to-use-it",level:2},{value:"Further Reading",id:"further-reading",level:2},{value:"Resources",id:"resources",level:2}];function h(e){let i={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",meta:"meta",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components},{Head:n,RuleAttributes:s,TryInPlayground:l}=i;return n||m("Head",!0),s||m("RuleAttributes",!0),l||m("TryInPlayground",!0),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(i.blockquote,{children:["\n",(0,t.jsx)(i.p,{children:"Require explicit accessibility modifiers on class properties and methods."}),"\n"]})}),"\n",(0,t.jsx)(s,{name:"explicit-member-accessibility"}),"\n","\n",(0,t.jsxs)(i.p,{children:["TypeScript allows placing explicit ",(0,t.jsx)(i.code,{children:"public"}),", ",(0,t.jsx)(i.code,{children:"protected"}),", and ",(0,t.jsx)(i.code,{children:"private"})," accessibility modifiers in front of class members.\nThe modifiers exist solely in the type system and just serve to describe who is allowed to access those members."]}),"\n",(0,t.jsxs)(i.p,{children:["Leaving off accessibility modifiers makes for less code to read and write.\nMembers are ",(0,t.jsx)(i.code,{children:"public"})," by default."]}),"\n",(0,t.jsx)(i.p,{children:"However, adding in explicit accessibility modifiers can be helpful in codebases with many classes for enforcing proper privacy of members.\nSome developers also find it preferable for code readability to keep member publicity explicit."}),"\n",(0,t.jsxs)(o.A,{children:[(0,t.jsx)(a.A,{value:"Flat Config",children:(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-js",metastring:'title="eslint.config.mjs"',children:'export default defineConfig({\n  rules: {\n    "@typescript-eslint/explicit-member-accessibility": "error"\n  }\n});\n'})})}),(0,t.jsx)(a.A,{value:"Legacy Config",children:(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-js",metastring:'title=".eslintrc.cjs"',children:'module.exports = {\n  "rules": {\
1n    "@typescript-eslint/explicit-member-accessibility": "error"\n  }\n};\n'})})})]}),"\n",(0,t.jsx)(l,{eslintrcHash:"N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdFDHQA9tEjgwAXxC6gA",children:(0,t.jsx)(i.p,{children:"Try this rule in the playground \u2197"})}),"\n",(0,t.jsx)(i.h2,{id:"examples",children:"Examples"}),"\n",(0,t.jsx)(i.p,{children:"This rule aims to make code more readable and explicit about who can use\nwhich properties."}),"\n",(0,t.jsx)(i.h2,{id:"options",children:"Options"}),"\n",(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(i.p,{children:"This rule accepts the following options:"})}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",children:"type AccessibilityLevel =\n  /** Always require an accessor. */\n  | 'explicit'\n  /** Never check whether there is an accessor. */\n  | 'off'\n  /** Require an accessor except when public. */\n  | 'no-public';\n\ntype Options = [\n  {\n    /** Which accessibility modifier is required to exist or not exist. */\n    accessibility?: AccessibilityLevel;\n    /** Specific method names that may be ignored. */\n    ignoredMethodNames?: string[];\n    /** Changes to required accessibility modifiers for specific kinds of class members. */\n    overrides?: {\n      /** Which member accessibility modifier requirements to apply for accessors. */\n      accessors?: AccessibilityLevel;\n      /** Which member accessibility modifier requirements to apply for constructors. */\n      constructors?: AccessibilityLevel;\n      /** Which member accessibility modifier requirements to apply for methods. */\n      methods?: AccessibilityLevel;\n      /** Which member accessibility modifier requirements to apply for parameterProperties. */\n      parameterProperties?: AccessibilityLevel;\n      /** Which member accessibility modifier requirements to apply for properties. */\n      properties?: AccessibilityLevel;\n    };\n  },\n];\n\nconst defaultOptions: Options = [{ accessibility: 'explicit' }];\n"})}),"\n",(0,t.jsx)(i.h3,{id:"configuring-in-a-mixed-jsts-codebase",children:"Configuring in a mixed JS/TS codebase"}),"\n",(0,t.jsxs)(i.p,{children:["If you are working on a codebase within which you lint non-TypeScript code (i.e. ",(0,t.jsx)(i.code,{children:".js"}),"/",(0,t.jsx)(i.code,{children:".mjs"}),"/",(0,t.jsx)(i.code,{children:".cjs"}),"/",(0,t.jsx)(i.code,{children:".jsx"}),"), you should ensure that you should use ",(0,t.jsxs)(i.a,{href:"https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files",children:["ESLint ",(0,t.jsx)(i.code,{children:"overrides"})]})," to only enable the rule on ",(0,t.jsx)(i.code,{children:".ts"}),"/",(0,t.jsx)(i.code,{children:".mts"}),"/",(0,t.jsx)(i.code,{children:".cts"}),"/",(0,t.jsx)(i.code,{children:".tsx"})," files. If you don't, then you will get unfixable lint errors reported within ",(0,t.jsx)(i.code,{children:".js"}),"/",(0,t.jsx)(i.code,{children:".mjs"}),"/",(0,t.jsx)(i.code,{children:".cjs"}),"/",(0,t.jsx)(i.code,{children:".jsx"})," files."]}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-jsonc",children:'{\n  "rules": {\n    // disable the rule for all files\n    "@typescript-eslint/explicit-member-accessibility": "off",\n  },\n  "overrides": [\n    {\n      // enable the rule specifically for TypeScript files\n      "files": ["*.ts", "*.mts", "*.cts", "*.tsx"],\n      "rules": {\n        "@typescript-eslint/explicit-member-accessibility": "error",\n      },\n    },\n  ],\n}\n'})}),"\n",(0,t.jsx)(i.h3,{id:"accessibility",children:(0,t.jsx)(i.code,{children:"accessibility"})}),"\n",(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(i.p,{children:["Which accessibility modifier is required to exist or not exist. Default: ",(0,t.jsx)(i.code,{children:'"explicit"'}),"."]})}),"\n","\n",(0,t.jsx)(i.p,{children:"This rule in its default state requires no configuration and will enforce that every class member has an accessibility modifier. If you would like to allow for some implicit public members then you have the following options:"}
1),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-jsonc",children:'{\n  "accessibility": "explicit",\n  "overrides": {\n    "accessors": "explicit",\n    "constructors": "no-public",\n    "methods": "explicit",\n    "properties": "off",\n    "parameterProperties": "explicit",\n  },\n}\n'})}),"\n",(0,t.jsx)(i.p,{children:"Note the above is an example of a possible configuration you could use - it is not the default configuration."}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered incorrect code if no options are provided:"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdFDHQA9tEjgwAXxC6gA"',children:"class Animal {\n  constructor(name) {\n    // No accessibility modifier\n    this.animalName = name;\n  }\n  animalName: string; // No accessibility modifier\n  get name(): string {\n    // No accessibility modifier\n    return this.animalName;\n  }\n  set name(value: string) {\n    // No accessibility modifier\n    this.animalName = value;\n  }\n  walk() {\n    // method\n  }\n}\n"})}),"\n",(0,t.jsxs)(i.p,{children:["The following patterns are considered correct with the default options ",(0,t.jsx)(i.code,{children:"{ accessibility: 'explicit' }"}),":"]}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "explicit" }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwisidulXvkjHsAXw8BdDd88gA"',children:"class Animal {\n  public constructor(\n    public breed,\n    name,\n  ) {\n    // Parameter property and constructor\n    this.animalName = name;\n  }\n  private animalName: string; // Property\n  get name(): string {\n    // get accessor\n    return this.animalName;\n  }\n  set name(value: string) {\n    // set accessor\n    this.animalName = value;\n  }\n  public walk() {\n    // method\n  }\n}\n"})}),"\n",(0,t.jsxs)(i.p,{children:["The following patterns are considered incorrect with the accessibility set to ",(0,t.jsx)(i.strong,{children:"no-public"})," ",(0,t.jsx)(i.code,{children:"[{ accessibility: 'no-public' }]"}),":"]}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "no-public" }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwishMdtYrGE9Ix7AF8vAXQ1fbyA"',children:"class Animal {\n  public constructor(\n    public breed,\n    name,\n  ) {\n    // Parameter property and constructor\n    this.animalName = name;\n  }\n  public animalName: string; // Property\n  public get name(): string {\n    // get accessor\n    return this.animalName;\n  }\n  public set name(value: string) {\n    // set accessor\n    this.animalName = value;\n  }\n  public walk() {\n    // method\n  }\n}\n"})}),"\n",(0,t.jsxs)(i.p,{children:["The following patterns are considered correct with the accessibility set to ",(0,t.jsx)(i.strong,{children:"no-public"})," ",(0,t.jsx)(i.code,{children:"[{ accessibility: 'no-public' }]"}),":"]}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "no-public" }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwishMdtYrGE9Ix7AF8vAXQ1fbyA"',children:"class Animal {\n  constructor(\n    protected breed,\n    name,\n  ) {\n    // Parameter property and constructor\n    this.name = name;\n  }\n  private animalName: string; // Property\n  get name(): string {\n    // get accessor\n    return this.animalName;\n  }\n  private set name(value: string) {\n    // set accessor\n    this.animalName = value;\n  }\n  protected walk() {\n    // method\n  }\n}\n"})}),"\n",(0,t.jsx)(i.h3,{id:"overrides",children:(0,t.jsx)(i.code,{children:"overrides"})}),"\n",(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(i.p,{children:"Changes to required accessibility modifiers for specific kinds of class members."})}),"\n","\n",(0,t.jsx)(i.p,{children:"There are three ways in which an override can be used."}),"\n",(0,t.jsxs)(i.ul,{children:["\n",(0,t.jsx)(i.li,{children:"To disallow the use of public on a given member."}),"\n",(0,t.jsx)(i.li,{children:"To enforce explicit member accessibility when the root has allowed implicit public accessibility"}),"\n",(0,t.jsx)(i.li,{children:"To disable any checks on given member type"}),"\n"]}),"\n",(0,t.jsx)(i.h4,{id:"disallow-the-use-of-public-on-a-given-member",children:"Disallow the use of public on a given member"}
1),"\n",(0,t.jsxs)(i.p,{children:["e.g. ",(0,t.jsx)(i.code,{children:"[ { overrides: { constructors: 'no-public' } } ]"})]}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered incorrect with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "overrides": { "constructors": "no-public" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskHQDdtlACYoVps+bI6myfHDL49qDJCYdWmJYYR5IYzMAX0iIGM0AXQ0YqKA"',children:"class Animal {\n  public constructor(protected animalName) {}\n  public get name() {\n    return this.animalName;\n  }\n}\n"})}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered correct with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "overrides": { "constructors": "no-public" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskHQDdtlACYoVps+bI6myfHDL49qDJCYdWmJYYR5IYzMAX0iIGM0AXQ0YqKA"',children:"class Animal {\n  constructor(protected animalName) {}\n  public get name() {\n    return this.animalName;\n  }\n}\n"})}),"\n",(0,t.jsx)(i.h4,{id:"require-explicit-accessibility-for-a-given-member",children:"Require explicit accessibility for a given member"}),"\n",(0,t.jsxs)(i.p,{children:["e.g. ",(0,t.jsx)(i.code,{children:"[ { accessibility: 'no-public', overrides: { properties: 'explicit' } } ]"})]}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered incorrect with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "no-public", "overrides": { "properties": "explicit" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwishMdtYrGE9Dxs5B0A3bZQAJigqpmbmxLqk0PiUIRiQnNyUvPiQXpoAvhlg2ZoAuhrZmUA"',children:"class Animal {\n  constructor(protected animalName) {}\n  get name() {\n    return this.animalName;\n  }\n  protected set name(value: string) {\n    this.animalName = value;\n  }\n  legs: number;\n  private hasFleas: boolean;\n}\n"})}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered correct with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "no-public", "overrides": { "properties": "explicit" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwishMdtYrGE9Dxs5B0A3bZQAJigqpmbmxLqk0PiUIRiQnNyUvPiQXpoAvhlg2ZoAuhrZmUA"',children:"class Animal {\n  constructor(protected animalName) {}\n  get name() {\n    return this.animalName;\n  }\n  protected set name(value: string) {\n    this.animalName = value;\n  }\n  public legs: number;\n  private hasFleas: boolean;\n}\n"})}),"\n",(0,t.jsxs)(i.p,{children:["e.g. ",(0,t.jsx)(i.code,{children:"[ { accessibility: 'off', overrides: { parameterProperties: 'explicit' } } ]"})]}),"\n",(0,t.jsx)(i.p,{children:"The following code is considered incorrect with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "off", "overrides": { "parameterProperties": "explicit" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwisg6AZk8PGzjgG7bKAExQqpmbmxBLQEoL4YgAKuqTQ+JQBGJCc3JS8+JDumgC+OWD5mgC6Gvm5QA"',children:"class Animal {\n  constructor(readonly animalName: string) {}\n}\n"})}),"\n",(0,t.jsx)(i.p,{children:"The following code patterns are considered correct with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "off", "overrides": { "parameterProperties": "explicit" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwisg6AZk8PGzjgG7bKAExQqpmbmxBLQEoL4YgAKuqTQ+JQBGJCc3JS8+JDumgC+OWD5mgC6Gvm5QA"',children:"class Animal {\n  
1constructor(public readonly animalName: string) {}\n}\n\nclass Animal {\n  constructor(public animalName: string) {}\n}\n\nclass Animal {\n  constructor(animalName: string) {}\n}\n"})}),"\n",(0,t.jsxs)(i.p,{children:["e.g. ",(0,t.jsx)(i.code,{children:"[ { accessibility: 'off', overrides: { parameterProperties: 'no-public' } } ]"})]}),"\n",(0,t.jsx)(i.p,{children:"The following code is considered incorrect with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "off", "overrides": { "parameterProperties": "no-public" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwisg6AZk8PGzjgG7bKAExQqpmbmxBLQEoL4YgAKuqTQ+JQBGJBMOrTEsMI8kO6aAL55YIWaALoahflAA"',children:"class Animal {\n  constructor(public readonly animalName: string) {}\n}\n"})}),"\n",(0,t.jsx)(i.p,{children:"The following code is considered correct with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "accessibility": "off", "overrides": { "parameterProperties": "no-public" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskKTORyFSwisg6AZk8PGzjgG7bKAExQqpmbmxBLQEoL4YgAKuqTQ+JQBGJBMOrTEsMI8kO6aAL55YIWaALoahflAA"',children:"class Animal {\n  constructor(public animalName: string) {}\n}\n"})}),"\n",(0,t.jsx)(i.h4,{id:"disable-any-checks-on-given-member-type",children:"Disable any checks on given member type"}),"\n",(0,t.jsxs)(i.p,{children:["e.g. ",(0,t.jsx)(i.code,{children:"[{ overrides: { accessors : 'off' } } ]"})]}),"\n",(0,t.jsx)(i.p,{children:"As no checks on the overridden member type are performed all permutations of visibility are permitted for that member type"}),"\n",(0,t.jsx)(i.p,{children:"The follow pattern is considered incorrect for the given configuration"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "overrides": { "accessors" : "off" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskHQDdtlACYoVps+akzkyPagwWAZj8jGZgC+gRAhmgC6GiFBQA"',children:"class Animal {\n  constructor(protected animalName) {}\n  public get name() {\n    return this.animalName;\n  }\n  get legs() {\n    return this.legCount;\n  }\n}\n"})}),"\n",(0,t.jsx)(i.p,{children:"The following patterns are considered correct with the example override"}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "overrides": { "accessors" : "off" } }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskHQDdtlACYoVps+akzkyPagwWAZj8jGZgC+gRAhmgC6GiFBQA"',children:"class Animal {\n  public constructor(protected animalName) {}\n  public get name() {\n    return this.animalName;\n  }\n  get legs() {\n    return this.legCount;\n  }\n}\n"})}),"\n",(0,t.jsx)(i.h3,{id:"ignoredmethodnames",children:(0,t.jsx)(i.code,{children:"ignoredMethodNames"})}),"\n",(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(i.p,{children:["Specific method names that may be ignored. Default: ",(0,t.jsx)(i.code,{children:"[]"}),"."]})}),"\n","\n",(0,t.jsxs)(i.p,{children:["Note that this option does not care about context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly.\ne.g. ",(0,t.jsx)(i.code,{children:"[ { ignoredMethodNames: ['specificMethod', 'whateverMethod'] } ]"})]}),"\n",(0,t.jsx)(i.pre,{children:(0,t.jsx)(i.code,{className:"language-ts",metastring:'option=\'{ "ignoredMethodNames": ["specificMethod", "whateverMethod"] }\' showPlaygroundButton eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6RAD2MbMroFtE-AEaJotAIZkyKZJWGVGRdGADa4bDjHQA9tEgAaDZqybskSgHMmexABMAsonwALHXYByEwagzqzZpDIpLwAZpRkTq7uhsYBUADuLhL4iABuYlFudpBxmgC6eWAAvnGFEKXFQA"',children:"class Animal {\n  get specificMethod() {\n    console.log('No error because you specified this method on option');\n  }\n  get whateverMethod() {\n    console.log('No error because you specified this method on option');\n  }\n  public get otherMethod() {\n    console.log('This method comply with this rule');\n  }\n}\n"})}),"\n",(0,t.jsx)(i.h2,{id:"when-not-to-use-it",children:"When Not To Use It"}),"\n",(0,t.jsxs)(i.p,{children:["If you think defaulting to public is a good default, then you should consider using the ",(0,t.jsx)(i.co
1de,{children:"no-public"})," setting.\nIf you want to mix implicit and explicit public members then you can disable this rule."]}),"\n",(0,t.jsx)(i.p,{children:"However, keep in mind that inconsistent style can harm readability in a project.\nWe recommend picking a single option for this rule that works best for your project."}),"\n",(0,t.jsx)(i.h2,{id:"further-reading",children:"Further Reading"}),"\n",(0,t.jsxs)(i.ul,{children:["\n",(0,t.jsxs)(i.li,{children:["TypeScript ",(0,t.jsx)(i.a,{href:"https://www.typescriptlang.org/docs/handbook/2/classes.html#member-visibility",children:"Accessibility Modifiers Handbook Docs"})]}),"\n"]}),"\n",(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.h2,{id:"resources",children:"Resources"}),"\n",(0,t.jsxs)(i.ul,{children:["\n",(0,t.jsx)(i.li,{children:(0,t.jsx)(i.a,{href:"https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts",children:"Rule source"})}),"\n",(0,t.jsx)(i.li,{children:(0,t.jsx)(i.a,{href:"https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts",children:"Test source"})}),"\n"]})]}),"\n",(0,t.jsx)(n,{children:(0,t.jsx)(i.meta,{content:"explicit-member-accessibility: Require explicit accessibility modifiers on class properties and methods",name:"twitter:image:alt"})})]})}function p(e={}){let{wrapper:i}={...(0,r.R)(),...e.components};return i?(0,t.jsx)(i,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}function m(e,i){throw Error("Expected "+(i?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}},46742(e,i,n){n.d(i,{A:()=>a});var s=n(65723);n(22155);var t=n(70851),r=n(28226);function o({children:e,className:i,hidden:n}){return(0,s.jsx)("div",{role:"tabpanel",className:(0,t.A)("tabItem_eQ9s",i),hidden:n,children:e})}function a({children:e,className:i,value:n}){let{selectedValue:t,lazy:l}=(0,r.uc)(),c=n===t;return!c&&l?null:(0,s.jsx)(o,{className:i,hidden:!c,children:e})}},70503(e,i,n){n.d(i,{A:()=>h});var s=n(65723);n(22155);var t=n(70851),r=n(98838),o=n(28226),a=n(26309),l=n(29021);function c({className:e}){let{selectedValue:i,selectValue:n,tabValues:r,block:l}=(0,o.uc)(),d=[],{blockElementScrollPositionUntilNextRender:u}=(0,a.a_)(),h=e=>{let s=e.currentTarget,t=r[d.indexOf(s)].value;t!==i&&(u(s),n(t))},p=e=>{let i=null;switch(e.key){case"Enter":h(e);break;case"ArrowRight":{let n=d.indexOf(e.currentTarget)+1;i=d[n]??d[0];break}case"ArrowLeft":{let n=d.indexOf(e.currentTarget)-1;i=d[n]??d[d.length-1]}}i?.focus()};return(0,s.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":l},e),children:r.map(({value:e,label:n,attributes:r})=>(0,s.jsx)("li",{role:"tab",tabIndex:i===e?0:-1,"aria-selected":i===e,ref:e=>{d.push(e)},onKeyDown:p,onClick:h,...r,className:(0,t.A)("tabs__item","tabItem_e1w9",r?.className,{"tabs__item--active":i===e}),children:n??e},e))})}function d({children:e}){return(0,s.jsx)("div",{className:"margin-top--md",children:e})}function u({className:e,children:i}){return(0,s.jsxs)("div",{className:(0,t.A)(r.G.tabs.container,"tabs-container","tabList_mVW_"),children:[(0,s.jsx)(c,{className:e}),(0,s.jsx)(d,{children:i})]})}function h(e){let i=(0,l.A)(),n=(0,o.OC)(e);return(0,s.jsx)(o.O_,{value:n,children:(0,s.jsx)(u,{className:e.className,children:(0,o.vT)(e.children)})},String(i))}},28226(e,i,n){n.d(i,{OC:()=>h,O_:()=>b,uc:()=>m,vT:()=>d});var s=n(65723),t=n(22155),r=n(62934),o=n(24127),a=n(12910),l=n(22399),c=n(6660);function d(e){return t.Children.toArray(e).filter(e=>"\n"!==e)}function u({value:e,tabValues:i}){return i.some(i=>i.value===e)}function h(e){let i,{defaultValue:n,queryString:s=!1,groupId:d}=e,h=function(e){let{values:i,children:n}=e;return(0,t.useMemo)(()=>{let e=i??t.Children.toArray(n).flatMap(e=>{if(!e)return[];if((0,t.isValidElement)(e)&&function(e){let{props:i}=e;return!!i&&"object"==typeof i&&"value"in i}(e))return[e];let i="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${i}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.
2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:i,attributes:n,default:s}})=>({value:e,label:i,attributes:n,default:s})),s=(0,l.XI)(e,(e,i)=>e.value===i.value);if(s.length>0)throw Error(`Docusaurus error: Duplicate values "${s.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[i,n])}(e),[p,m]=(0,t.useState)(()=>(function({defaultValue:e,tabValues:i}){if(0===i.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!u({value:e,tabValues:i}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${i.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let n=i.find(e=>e.default)??i[0];if(!n)throw Error("Unexpected error: 0 tabValues");return n.value})({defaultValue:n,tabValues:h})),[b,A]=function({queryString:e=!1,groupId:i}){let n=(0,r.W6)(),s=function({queryString:e=!1,groupId:i}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!i)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:e,groupId:i});return[(0,a.aZ)(s),(0,t.useCallback)(e=>{if(!s)return;let i=new URLSearchParams(n.location.search);i.set(s,e),n.replace({...n.location,search:i.toString()})},[s,n])]}({queryString:s,groupId:d}),[g,x]=function({groupId:e}){let i=e?`docusaurus.tab.${e}`:null,[n,s]=(0,c.Dv)(i);return[n,(0,t.useCallback)(e=>{i&&s.set(e)},[i,s])]}({groupId:d}),y=u({value:i=b??g,tabValues:h})?i:null;return(0,o.A)(()=>{y&&m(y)},[y]),{selectedValue:p,selectValue:(0,t.useCallback)(e=>{if(!u({value:e,tabValues:h}))throw Error(`Can't select invalid tab value=${e}`);m(e),A(e),x(e)},[A,x,h]),tabValues:h,lazy:e.lazy??!1,block:e.block??!1}}let p=(0,t.createContext)(null);function m(){let e=t.useContext(p);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function b(e){return(0,s.jsx)(p.Provider,{value:e.value,children:e.children})}},7143(e,i,n){n.d(i,{R:()=>o,x:()=>a});var s=n(22155);let t={},r=s.createContext(t);function o(e){let i=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function a(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),s.createElement(r.Provider,{value:i},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.