javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Add Class Private Identifier

Open DawChihLiou opened this issue 2 years ago • 5 comments

Include Private Class Member (# name)

Hi Maintainers👋

I would like to make a modification for private class members. ECMA2022 standardized the private identifier #. It marks class members as private.

Additional Section:

  • 9.8 Class members should use # to mark them as private members.

Modified Section:

  • 23.4 Do not use trailing or leading underscores.

References:

DawChihLiou avatar Jan 04 '22 06:01 DawChihLiou

This isn't something the guide can support until babel-preset-airbnb transforms them, and until eslint fully supports linting them with ecmaVersion 2022, which I don't think it quite does yet.

ljharb avatar Jan 04 '22 06:01 ljharb

This isn't something the guide can support until babel-preset-airbnb transforms them, and until eslint fully supports linting them with ecmaVersion 2022, which I don't think it quite does yet.

I did some research and found out that ESLint seems to lint private class member since v8.1.0.

DawChihLiou avatar Jan 04 '22 06:01 DawChihLiou

That’s great - but our eslint config still supports eslint 7, so we wouldn’t be able to recommend using private fields (which are great) until we drop eslint < 8.1.

ljharb avatar Jan 04 '22 14:01 ljharb

Understood. Thanks for taking the time:)

DawChihLiou avatar Jan 05 '22 05:01 DawChihLiou

@Jassi10000 while that's technically true, it's not that important until the PR is ready to be merged - and it's something maintainers can often take care of.

ljharb avatar Feb 03 '22 17:02 ljharb