Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use ESLint v9 in examples #264

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion examples/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function App({ name }) {

```sh
$ git clone https://github.com/eslint/eslint-plugin-markdown.git
$ cd eslint-plugin-markdown/examples/react
$ cd eslint-plugin-markdown
$ npm install
$ cd examples/react
$ npm test
Comment on lines 14 to 18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary to install dependencies from the root because config uses the plugin module directly:

https://github.com/eslint/eslint-plugin-markdown/blob/e0da2214cc06fd441def1844135f3c9fef74e940/examples/react/eslint.config.mjs#L3


eslint-plugin-markdown/examples/react/README.md
Expand Down
10 changes: 2 additions & 8 deletions examples/react/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import js from "@eslint/js";
import markdown from "../../src/index.js";
import globals from "globals";
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
import reactPlugin from "eslint-plugin-react";

export default [
js.configs.recommended,
...markdown.configs.recommended,
reactRecommended,
reactPlugin.configs.flat.recommended,
{
settings: {
react: {
Expand All @@ -25,12 +25,6 @@ export default [
globals: globals.browser
}
},
{
files: ["eslint.config.js"],
languageOptions: {
sourceType: "commonjs"
}
},
{
files: ["**/*.md/*.jsx"],
languageOptions: {
Expand Down
7 changes: 3 additions & 4 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"test": "eslint ."
},
"devDependencies": {
"@eslint/js": "^8.56.0",
"eslint": "^8.56.0",
"eslint-plugin-markdown": "file:../..",
"eslint-plugin-react": "^7.20.3",
"@eslint/js": "^9.7.0",
"eslint": "^9.7.0",
"eslint-plugin-react": "^7.35.0",
"globals": "^13.24.0"
}
}
7 changes: 4 additions & 3 deletions examples/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ hello(42 as any);

```sh
$ git clone https://github.com/eslint/eslint-plugin-markdown.git
$ cd eslint-plugin-markdown/examples/typescript
$ cd eslint-plugin-markdown
$ npm install
$ cd examples/typescript
$ npm test

eslint-plugin-markdown/examples/typescript/README.md
6:22 error Don't use `String` as a type. Use string instead @typescript-eslint/ban-types
10:13 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
6:22 error Prefer using the primitive `string` as a type name, rather than the upper-cased `String` @typescript-eslint/no-wrapper-object-types
10:13 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

✖ 2 problems (2 errors, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Expand Down
6 changes: 0 additions & 6 deletions examples/typescript/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import tseslint from "typescript-eslint";
export default tseslint.config(
js.configs.recommended,
...markdown.configs.recommended,
{
files: ["eslint.config.js"],
languageOptions: {
sourceType: "commonjs"
}
},
...tseslint.configs.recommended.map(config => ({
...config,
files: ["**/*.ts"]
Expand Down
7 changes: 3 additions & 4 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"test": "eslint ."
},
"devDependencies": {
"@eslint/js": "^8.56.0",
"eslint": "^8.56.0",
"eslint-plugin-markdown": "file:../..",
"@eslint/js": "^9.7.0",
"eslint": "^9.7.0",
"typescript": "^5.3.3",
"typescript-eslint": "^7.0.1"
"typescript-eslint": "8.0.0-alpha.51"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the latest prerelease. We'll need to use a prerelease version because v7 doesn't support ESLint 9. When final v8 is released, this should be changed to "^8.0.0".

}
}
8 changes: 4 additions & 4 deletions tests/examples/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const examples = fs.readdirSync(examplesDir)
for (const example of examples) {
const cwd = path.join(examplesDir, example);

// The plugin officially supports ESLint as early as v6, but the examples
// use ESLint v8, which has a higher minimum Node.js version than does v6.
// In case when this plugin supports multiple major versions of ESLint,
// CI matrix may include Node.js versions that are not supported by
// the version of ESLint that is used in examples.
// Only exercise the example if the running Node.js version satisfies the
// minimum version constraint. In CI, this will skip these tests in Node.js
// v8 and run them on all other Node.js versions.
// minimum version constraint.
const eslintPackageJsonPath = require.resolve("eslint/package.json", {
paths: [cwd]
});
Expand Down