Skip to content

Commit

Permalink
chore: deprecate node-dupe-class-member (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus authored Nov 10, 2021
1 parent d19c3aa commit 38799ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ Older browsers like IE11 run LWC in compatibility mode. For more information abo
| [lwc/no-async-await](./docs/rules/no-async-await.md) | disallow usage of the async-await syntax | |
| [lwc/no-for-of](./docs/rules/no-for-of.md) | disallow usage of the for-of syntax | |
| [lwc/no-rest-parameter](./docs/rules/no-rest-parameter.md) | disallow usage of the rest parameter syntax | |

### Deprecated

| Rule ID | Replaced by |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md) | [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members) |
4 changes: 2 additions & 2 deletions docs/rules/no-dupe-class-members.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Disallow duplicate class members (no-dupe-class-members)

If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. This can cause unexpected behaviors. This rule prevents usage of duplicate class members (fields and methods) on the same class.
> ⚠️ This rule is deprecated. It can be replaced by ESLint builtin [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members) rule. ⚠️
> Note: This rule extends the original eslint rule [`no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) to add support for [class fields](https://github.com/tc39/proposal-class-fields) that are not yet stage 4.
If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. This can cause unexpected behaviors. This rule prevents usage of duplicate class members (fields and methods) on the same class.

## Rule details

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-dupe-class-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ module.exports = {
messages: {
unexpected: "Duplicate name '{{name}}'.",
},

deprecated: true,
replacedBy: ['no-dupe-class-members'],
},

create(context) {
Expand Down
6 changes: 6 additions & 0 deletions test/lib/rules/no-dupe-class-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@

const semver = require('semver');
const eslint = require('eslint');
const assert = require('assert');

const { ESLINT_TEST_CONFIG } = require('../shared');
const rule = require('../../../lib/rules/no-dupe-class-members');

const ruleTester = new eslint.RuleTester(ESLINT_TEST_CONFIG);

const isEslint7 = semver.satisfies(eslint.ESLint.version, '^7');

it('no-dupe-class-member should be deprecated', () => {
assert.equal(rule.meta.deprecated, true);
});

ruleTester.run('no-dupe-class-members', rule, {
valid: [
// Original rule tests:
Expand Down

0 comments on commit 38799ea

Please sign in to comment.