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

feat!: Switch to flat config #232

Merged
merged 21 commits into from
Feb 15, 2024
Merged

feat!: Switch to flat config #232

merged 21 commits into from
Feb 15, 2024

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Jan 31, 2024

  • Switch recommended config to flat config format
  • Rename old recommended config to recommended-legacy
  • Updated documentation
  • Upgraded ESLint and associated plugins
  • Updated tests

fixes #231

- Switch recommended config to flat config format
- Rename old recommended config to recommended-legacy
- Updated documentation
- Upgraded ESLint
- Updated tests

fixes #231
@nzakas
Copy link
Member Author

nzakas commented Feb 2, 2024

Ping @eslint/eslint-team

@@ -17,15 +17,28 @@ Lint JS, JSX, TypeScript, and more inside Markdown.

### Installing

Install the plugin alongside ESLint v6 or greater:
Install the plugin alongside ESLint v8 or greater:
Copy link
Member

Choose a reason for hiding this comment

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

Which versions of ESLint will be officially supported? Per this sentence and the CI update, it looks like only >=8. However, there are still instructions for v6 and v7 below, and package.json still has "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" } .

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to update the supported ESLint versions in another PR.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
eslint: [6, 7, 8]
node: [12.22.0, 14, 16, 17, 18, 19, 20, 21]
eslint: [8]
node: [16, 17, 18, 19, 20, 21]
Copy link
Member

Choose a reason for hiding this comment

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

this also dropped some node.js/eslint versions support. To reflect this in the generated changelog:

  1. update the PR title.
  2. put these changes to a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

These changes are necessary to make CI pass. I'll officially change the Node.js supported versions in a separate PR.

@@ -29,14 +29,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
eslint: [6, 7, 8]
node: [12.22.0, 14, 16, 17, 18, 19, 20, 21]
Copy link
Member

Choose a reason for hiding this comment

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

If we want to drop support for Node < 16, we should also update the engines field in package.json.

Copy link
Member Author

Choose a reason for hiding this comment

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

As previously mentioned, I'm going to update Node.js support in a separate PR so it comes out in the changelog.

README.md Outdated Show resolved Hide resolved
nzakas and others added 3 commits February 5, 2024 13:12
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: 唯然 <[email protected]>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
// the plugin, so we need to make sure it's resolvable and link it
// if not.

// eslint-disable-next-line n/no-missing-require -- Known possible failure.
Copy link
Member

Choose a reason for hiding this comment

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

Now that the eslint config for this project enables reporting unused disable directives, this directive is reported when linting is run after npm test, which is confusing. It might be best to allow requiring eslint-plugin-markdown from this file and remove this directive (and the same one on line 1065).

// in eslint.config.js
{
    files: ["tests/lib/plugin.js"],
    rules: {
        "n/no-missing-require": ["error", {
            allowModules: ["eslint-plugin-markdown"]
        }]
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

Actually, we can now just remove the whole try-catch (lines 73-95 and 1059-1081) as there's no need to install eslint-plugin-markdown in node_modules.

As of ESLint v8.1.0 (eslint/eslint@a1f7ad7), plugin implementations passed to the constructor are used when resolving extends:["plugin:plugin-name/config-name"] as well. In this case, eslint-plugin-markdown implementation we're already passing to the ESLint constructor will be used to get the "plugin:markdown/recommended-legacy" config from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good catch!

examples/react/eslint.config.js Outdated Show resolved Hide resolved
examples/typescript/eslint.config.js Outdated Show resolved Hide resolved
module.exports = [
js.configs.recommended,
...markdown.configs.recommended,
...compat.extends("plugin:react/recommended"),
Copy link
Member

Choose a reason for hiding this comment

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

As of v7.32.0, eslint-plugin-react has an additional export for the recommended config in flat config format, so we could use that for this example:

require('eslint-plugin-react/configs/recommended') // this is a flat config object

cwd: path.resolve(__dirname, "../fixtures/"),
ignore: false,
overrideConfigFile: path.resolve(__dirname, "../fixtures/", fixtureConfigName),
plugins: { markdown: plugin },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
plugins: { markdown: plugin },

This doesn't seem necessary as the config files load the plugin.

nzakas and others added 10 commits February 9, 2024 13:42
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
tests/lib/plugin.js Outdated Show resolved Hide resolved
Co-authored-by: Milos Djermanovic <[email protected]>
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 7a27eef into main Feb 15, 2024
12 checks passed
@mdjermanovic mdjermanovic deleted the issue231 branch February 15, 2024 12:52
@github-actions github-actions bot mentioned this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flat config
3 participants