Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b9d6c28
feat: add no-property-in-node rule
JoshuaKGoldberg Feb 5, 2024
8cfaf6d
Add ☑️ emoji for recommended-type-checked
JoshuaKGoldberg Feb 5, 2024
4d163e1
tests: valid before invalid
JoshuaKGoldberg Feb 5, 2024
d62539d
Also check for whether the node has a 'type'
JoshuaKGoldberg Feb 5, 2024
3575644
Added docs and example to isAstNodeType
JoshuaKGoldberg Feb 5, 2024
e42c075
Expanded rule details
JoshuaKGoldberg Feb 5, 2024
2a94dcb
Add more valid test cases
JoshuaKGoldberg Feb 5, 2024
4d5d332
Merge branch 'main'
JoshuaKGoldberg Feb 5, 2024
755cc08
Fixed test path to fixtures
JoshuaKGoldberg Feb 5, 2024
d76b08a
Use parserOptions.project: true for eslint-remote-tester on TS files
JoshuaKGoldberg Feb 5, 2024
5913127
nit: avoid shadowing name for typePart
JoshuaKGoldberg Feb 5, 2024
d45695d
<!-- omit from toc -->
JoshuaKGoldberg Feb 5, 2024
532925d
Downgraded to typescript-eslint@v5
JoshuaKGoldberg Feb 6, 2024
6b60ab0
Also remove @typescript-eslint/utils
JoshuaKGoldberg Feb 6, 2024
89aafda
Or rather, make @typescript-eslint/utils a -D
JoshuaKGoldberg Feb 6, 2024
1d570e8
Remove ts-api-utils too
JoshuaKGoldberg Feb 6, 2024
1ec0c2a
Removed recommended-type-checked
JoshuaKGoldberg Feb 6, 2024
de370b0
Removed README.md section too
JoshuaKGoldberg Feb 6, 2024
18b205a
Removed eslint-remote-tester.config.js parserOptions.project too
JoshuaKGoldberg Feb 6, 2024
8d68dc9
Redid README.md presets table
JoshuaKGoldberg Feb 6, 2024
d8dc1a0
Added all-type-checked
JoshuaKGoldberg Feb 6, 2024
d8cc468
Removed file notice
JoshuaKGoldberg Feb 6, 2024
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
Prev Previous commit
Next Next commit
Merge branch 'main'
  • Loading branch information
JoshuaKGoldberg committed Feb 5, 2024
commit 4d5d332559653d568b949345fe5a57519193f024
130 changes: 68 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ An ESLint plugin for linting ESLint plugins. Rules written in CJS, ESM, and Type

<!-- vscode-markdown-toc -->

* [Installation](#Installation)
* [Usage](#Usage)
* [Rules](#Rules)
* [Presets](#Presets)
* [Semantic versioning policy](#Semanticversioningpolicy)
* [Preset usage](#Presetusage)
- [eslint-plugin-eslint-plugin ](#eslint-plugin-eslint-plugin---)
- [Installation](#installation)
- [Usage](#usage)
- [**.eslintrc.json**](#eslintrcjson)
- [`eslint.config.js` (requires eslint\>=v8.23.0)](#eslintconfigjs-requires-eslintv8230)
- [Type Checked Rules](#type-checked-rules)
- [Rules](#rules)
- [Rules](#rules-1)
- [Tests](#tests)
- [Presets](#presets)
- [Semantic versioning policy](#semantic-versioning-policy)
- [Preset usage](#preset-usage)

<!-- vscode-markdown-toc-config
numbering=false
Expand Down Expand Up @@ -77,12 +83,12 @@ If your plugin is authored in TypeScript, we recommend replacing `recommended` w

```js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
extends: ['plugin:eslint-plugin/recommended-type-checked'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
extends: ['plugin:eslint-plugin/recommended-type-checked'],
};
```

Expand All @@ -99,54 +105,54 @@ module.exports = {

### Rules

| Name                          | Description | 💼 | 🔧 | 💡 | 💭 |
| :--------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :--- | :- | :- | :- |
| [fixer-return](docs/rules/fixer-return.md) | require fixer functions to return a fix | ✅ ☑️ | | | |
| [meta-property-ordering](docs/rules/meta-property-ordering.md) | enforce the order of meta properties | | 🔧 | | |
| [no-deprecated-context-methods](docs/rules/no-deprecated-context-methods.md) | disallow usage of deprecated methods on rule context objects | ✅ ☑️ | 🔧 | | |
| [no-deprecated-report-api](docs/rules/no-deprecated-report-api.md) | disallow the version of `context.report()` with multiple arguments | ✅ ☑️ | 🔧 | | |
| [no-missing-message-ids](docs/rules/no-missing-message-ids.md) | disallow `messageId`s that are missing from `meta.messages` | ✅ ☑️ | | | |
| [no-missing-placeholders](docs/rules/no-missing-placeholders.md) | disallow missing placeholders in rule report messages | ✅ ☑️ | | | |
| [no-property-in-node](docs/rules/no-property-in-node.md) | disallow using `in` to narrow node types instead of looking at properties | ☑️ | | | 💭 |
| [no-unused-message-ids](docs/rules/no-unused-message-ids.md) | disallow unused `messageId`s in `meta.messages` | ✅ ☑️ | | | |
| [no-unused-placeholders](docs/rules/no-unused-placeholders.md) | disallow unused placeholders in rule report messages | ✅ ☑️ | | | |
| [no-useless-token-range](docs/rules/no-useless-token-range.md) | disallow unnecessary calls to `sourceCode.getFirstToken()` and `sourceCode.getLastToken()` | ✅ ☑️ | 🔧 | | |
| [prefer-message-ids](docs/rules/prefer-message-ids.md) | require using `messageId` instead of `message` or `desc` to report rule violations | ✅ ☑️ | | | |
| [prefer-object-rule](docs/rules/prefer-object-rule.md) | disallow function-style rules | ✅ ☑️ | 🔧 | | |
| [prefer-placeholders](docs/rules/prefer-placeholders.md) | require using placeholders for dynamic report messages | | | | |
| [prefer-replace-text](docs/rules/prefer-replace-text.md) | require using `replaceText()` instead of `replaceTextRange()` | | | | |
| [report-message-format](docs/rules/report-message-format.md) | enforce a consistent format for rule report messages | | | | |
| [require-meta-docs-description](docs/rules/require-meta-docs-description.md) | require rules to implement a `meta.docs.description` property with the correct format | | | | |
| [require-meta-docs-url](docs/rules/require-meta-docs-url.md) | require rules to implement a `meta.docs.url` property | | 🔧 | | |
| [require-meta-fixable](docs/rules/require-meta-fixable.md) | require rules to implement a `meta.fixable` property | ✅ ☑️ | | | |
| [require-meta-has-suggestions](docs/rules/require-meta-has-suggestions.md) | require suggestable rules to implement a `meta.hasSuggestions` property | ✅ ☑️ | 🔧 | | |
| [require-meta-schema](docs/rules/require-meta-schema.md) | require rules to implement a `meta.schema` property | ✅ ☑️ | | 💡 | |
| [require-meta-type](docs/rules/require-meta-type.md) | require rules to implement a `meta.type` property | ✅ ☑️ | | | |
| Name                          | Description | 💼 | 🔧 | 💡 | 💭 |
| :--------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :---- | :-- | :-- | :-- |
| [fixer-return](docs/rules/fixer-return.md) | require fixer functions to return a fix | ✅ ☑️ | | | |
| [meta-property-ordering](docs/rules/meta-property-ordering.md) | enforce the order of meta properties | | 🔧 | | |
| [no-deprecated-context-methods](docs/rules/no-deprecated-context-methods.md) | disallow usage of deprecated methods on rule context objects | ✅ ☑️ | 🔧 | | |
| [no-deprecated-report-api](docs/rules/no-deprecated-report-api.md) | disallow the version of `context.report()` with multiple arguments | ✅ ☑️ | 🔧 | | |
| [no-missing-message-ids](docs/rules/no-missing-message-ids.md) | disallow `messageId`s that are missing from `meta.messages` | ✅ ☑️ | | | |
| [no-missing-placeholders](docs/rules/no-missing-placeholders.md) | disallow missing placeholders in rule report messages | ✅ ☑️ | | | |
| [no-property-in-node](docs/rules/no-property-in-node.md) | disallow using `in` to narrow node types instead of looking at properties | ☑️ | | | 💭 |
| [no-unused-message-ids](docs/rules/no-unused-message-ids.md) | disallow unused `messageId`s in `meta.messages` | ✅ ☑️ | | | |
| [no-unused-placeholders](docs/rules/no-unused-placeholders.md) | disallow unused placeholders in rule report messages | ✅ ☑️ | | | |
| [no-useless-token-range](docs/rules/no-useless-token-range.md) | disallow unnecessary calls to `sourceCode.getFirstToken()` and `sourceCode.getLastToken()` | ✅ ☑️ | 🔧 | | |
| [prefer-message-ids](docs/rules/prefer-message-ids.md) | require using `messageId` instead of `message` or `desc` to report rule violations | ✅ ☑️ | | | |
| [prefer-object-rule](docs/rules/prefer-object-rule.md) | disallow function-style rules | ✅ ☑️ | 🔧 | | |
| [prefer-placeholders](docs/rules/prefer-placeholders.md) | require using placeholders for dynamic report messages | | | | |
| [prefer-replace-text](docs/rules/prefer-replace-text.md) | require using `replaceText()` instead of `replaceTextRange()` | | | | |
| [report-message-format](docs/rules/report-message-format.md) | enforce a consistent format for rule report messages | | | | |
| [require-meta-docs-description](docs/rules/require-meta-docs-description.md) | require rules to implement a `meta.docs.description` property with the correct format | | | | |
| [require-meta-docs-url](docs/rules/require-meta-docs-url.md) | require rules to implement a `meta.docs.url` property | | 🔧 | | |
| [require-meta-fixable](docs/rules/require-meta-fixable.md) | require rules to implement a `meta.fixable` property | ✅ ☑️ | | | |
| [require-meta-has-suggestions](docs/rules/require-meta-has-suggestions.md) | require suggestable rules to implement a `meta.hasSuggestions` property | ✅ ☑️ | 🔧 | | |
| [require-meta-schema](docs/rules/require-meta-schema.md) | require rules to implement a `meta.schema` property | ✅ ☑️ | | 💡 | |
| [require-meta-type](docs/rules/require-meta-type.md) | require rules to implement a `meta.type` property | ✅ ☑️ | | | |

### Tests

| Name                        | Description | 💼 | 🔧 | 💡 | 💭 |
| :----------------------------------------------------------------------- | :--------------------------------------------------------------------------- | :--- | :- | :- | :- |
| [consistent-output](docs/rules/consistent-output.md) | enforce consistent use of `output` assertions in rule tests | ✅ ☑️ | | | |
| [no-identical-tests](docs/rules/no-identical-tests.md) | disallow identical tests | ✅ ☑️ | 🔧 | | |
| [no-only-tests](docs/rules/no-only-tests.md) | disallow the test case property `only` | ✅ ☑️ | | 💡 | |
| [prefer-output-null](docs/rules/prefer-output-null.md) | disallow invalid RuleTester test cases where the `output` matches the `code` | ✅ ☑️ | 🔧 | | |
| [test-case-property-ordering](docs/rules/test-case-property-ordering.md) | require the properties of a test case to be placed in a consistent order | | 🔧 | | |
| [test-case-shorthand-strings](docs/rules/test-case-shorthand-strings.md) | enforce consistent usage of shorthand strings for test cases with no options | | 🔧 | | |
| Name                        | Description | 💼 | 🔧 | 💡 | 💭 |
| :----------------------------------------------------------------------- | :--------------------------------------------------------------------------- | :---- | :-- | :-- | :-- |
| [consistent-output](docs/rules/consistent-output.md) | enforce consistent use of `output` assertions in rule tests | ✅ ☑️ | | | |
| [no-identical-tests](docs/rules/no-identical-tests.md) | disallow identical tests | ✅ ☑️ | 🔧 | | |
| [no-only-tests](docs/rules/no-only-tests.md) | disallow the test case property `only` | ✅ ☑️ | | 💡 | |
| [prefer-output-null](docs/rules/prefer-output-null.md) | disallow invalid RuleTester test cases where the `output` matches the `code` | ✅ ☑️ | 🔧 | | |
| [test-case-property-ordering](docs/rules/test-case-property-ordering.md) | require the properties of a test case to be placed in a consistent order | | 🔧 | | |
| [test-case-shorthand-strings](docs/rules/test-case-shorthand-strings.md) | enforce consistent usage of shorthand strings for test cases with no options | | 🔧 | | |

<!-- end auto-generated rules list -->

## <a name='Presets'></a>Presets

| | Name | Description |
| | Name | Description |
| :-- | :------------------------- | :--------------------------------------------------------------------------------------- |
| ✅ | `recommended` | enables all recommended rules in this plugin, excluding those requiring type information |
| | `recommended-type-checked` | enables all recommended rules in this plugin, including those requiring type information |
| | `rules-recommended` | enables all recommended rules that are aimed at linting ESLint rule files |
| | `tests-recommended` | enables all recommended rules that are aimed at linting ESLint test files |
| | `all` | enables all rules in this plugin |
| | `rules` | enables all rules that are aimed at linting ESLint rule files |
| | `tests` | enables all rules that are aimed at linting ESLint test files |
| ✅ | `recommended` | enables all recommended rules in this plugin, excluding those requiring type information |
| | `recommended-type-checked` | enables all recommended rules in this plugin, including those requiring type information |
| | `rules-recommended` | enables all recommended rules that are aimed at linting ESLint rule files |
| | `tests-recommended` | enables all recommended rules that are aimed at linting ESLint test files |
| | `all` | enables all rules in this plugin |
| | `rules` | enables all rules that are aimed at linting ESLint rule files |
| | `tests` | enables all rules that are aimed at linting ESLint test files |

### <a name='Semanticversioningpolicy'></a>Semantic versioning policy

Expand All @@ -158,23 +164,23 @@ Presets are enabled by adding a line to the `extends` list in your config file.

```json
{
"extends": ["plugin:eslint-plugin/recommended"]
"extends": ["plugin:eslint-plugin/recommended"]
}
```

Or to apply linting only to the appropriate rule or test files:

```json
{
"overrides": [
{
"files": ["lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/rules-recommended"]
},
{
"files": ["tests/lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/tests-recommended"]
}
]
"overrides": [
{
"files": ["lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/rules-recommended"]
},
{
"files": ["tests/lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/tests-recommended"]
}
]
}
```
12 changes: 8 additions & 4 deletions docs/rules/no-property-in-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Examples of **incorrect** code for this rule:

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: { /* ... */ },
meta: {
/* ... */
},
create(context) {
return {
'ClassDeclaration, FunctionDeclaration'(node) {
if ('superClass' in node) {
console.log("This is a class declaration:", node);
console.log('This is a class declaration:', node);
}
},
};
Expand All @@ -40,12 +42,14 @@ Examples of **correct** code for this rule:

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: { /* ... */ },
meta: {
/* ... */
},
create(context) {
return {
'ClassDeclaration, FunctionDeclaration'(node) {
if (node.type === 'ClassDeclaration') {
console.log("This is a class declaration:", node);
console.log('This is a class declaration:', node);
}
},
};
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.