Skip to content

Commit

Permalink
docs: update to eslint v9 in custom-rule-tutorial (#18383)
Browse files Browse the repository at this point in the history
* docs: update rule tester options in custom-rule-tutorial

Fixes #18382

* chore: update examples

* chore: update more places to eslint v9
  • Loading branch information
aladdin-add committed Apr 23, 2024
1 parent b4d2512 commit f12a02c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @fileoverview Tests for enforce-foo-bar.js rule.
* @author Ben Perlmutter
*/
Expand All @@ -10,7 +10,7 @@ const fooBarRule = require("./enforce-foo-bar");
const ruleTester = new RuleTester({
// Must use at least ecmaVersion 2015 because
// that's when `const` variable were introduced.
parserOptions: { ecmaVersion: 2015 }
languageOptions: { ecmaVersion: 2015 }
});

// Throws error if the tests in ruleTester.run() do not pass
Expand All @@ -31,4 +31,4 @@ ruleTester.run(
}
);

console.log("All tests passed!");
console.log("All tests passed!");
7 changes: 4 additions & 3 deletions docs/_examples/custom-rule-tutorial-code/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "eslint-plugin-example",
"private": true,
"version": "1.0.0",
"description": "ESLint plugin for enforce-foo-bar rule.",
"main": "eslint-plugin-example.js",
Expand All @@ -9,14 +10,14 @@
"eslint-plugin"
],
"peerDependencies": {
"eslint": ">=8.0.0"
"eslint": ">=9.0.0"
},
"scripts": {
"test": "node enforce-foo-bar.test.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.36.0"
"eslint": "^9.1.1"
}
}
}
3 changes: 2 additions & 1 deletion docs/_examples/integration-tutorial-code/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "_integration-tutorial-code",
"private": true,
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand All @@ -10,6 +11,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"eslint": "^8.39.0"
"eslint": "^9.1.1"
}
}
10 changes: 5 additions & 5 deletions docs/src/extend/custom-rule-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const fooBarRule = require("./enforce-foo-bar");
const ruleTester = new RuleTester({
// Must use at least ecmaVersion 2015 because
// that's when `const` variables were introduced.
parserOptions: { ecmaVersion: 2015 }
languageOptions: { ecmaVersion: 2015 }
});

// Throws error if the tests in ruleTester.run() do not pass
Expand Down Expand Up @@ -362,7 +362,7 @@ To publish a plugin containing a rule to npm, you need to configure the `package
1. `"name"`: A unique name for the package. No other package on npm can have the same name.
1. `"main"`: The relative path to the plugin file. Following this example, the path is `"eslint-plugin-example.js"`.
1. `"description"`: A description of the package that's viewable on npm.
1. `"peerDependencies"`: Add `"eslint": ">=8.0.0"` as a peer dependency. Any version greater than or equal to that is necessary to use the plugin. Declaring `eslint` as a peer dependency requires that users add the package to the project separately from the plugin.
1. `"peerDependencies"`: Add `"eslint": ">=9.0.0"` as a peer dependency. Any version greater than or equal to that is necessary to use the plugin. Declaring `eslint` as a peer dependency requires that users add the package to the project separately from the plugin.
1. `"keywords"`: Include the standard keywords `["eslint", "eslintplugin", "eslint-plugin"]` to make the package easy to find. You can add any other keywords that might be relevant to your plugin as well.

A complete annotated example of what a plugin's `package.json` file should look like:
Expand All @@ -379,9 +379,9 @@ A complete annotated example of what a plugin's `package.json` file should look
"scripts": {
"test": "node enforce-foo-bar.test.js"
},
// Add eslint>=8.0.0 as a peer dependency.
// Add eslint>=9.0.0 as a peer dependency.
"peerDependencies": {
"eslint": ">=8.0.0"
"eslint": ">=9.0.0"
},
// Add these standard keywords to make plugin easy to find!
"keywords": [
Expand All @@ -392,7 +392,7 @@ A complete annotated example of what a plugin's `package.json` file should look
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.36.0"
"eslint": "^9.0.0"
}
}
```
Expand Down

0 comments on commit f12a02c

Please sign in to comment.