Closed brettz9 closed 2 months ago
Want to try and work on this a bit. Trying to follow the pattern in eslint-plugin-n
import promise from 'eslint-plugin-promise';
/// TODO: Get the package name and version from package.json
const mod = {
meta: {
name: 'eslint-plugin-promise', /// pkg.name,
version: '6.1.1', /// pkg.version,
},
rules: promise.rules, /// the rule definitions
}
const recommendedConfig = {
flat: {
languageOptions: {}, /// no language options for promise that I know of
rules: promise.configs.recommended.rules, /// the rules we are applying
}
}
/// really not sure how the eslint-plugin-promise wants to expose their
/// but here is a sort of guess.
mod.configs = {
"flat/recommended": [
{
plugins: {
promise: mod
},
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
...recommendedConfig.flat
},
],
}
export default mod;
usage in flat file is something like:
// files: eslint.config.mjs
import promise from './eslint-plugin-promise-flat.mjs';
const flatConfig = promise.configs["flat/recommended"];
const eslintConfigObjects = [
...flatConfig,
];
export default eslintConfigObjects;
but when actually linting say no-promise-in-callback
, getAncestors
is undefined.
The line of code is here.
So, not quite sure why this is happening.
Some of the APIs have been dropped in ESLint 9. context.getAncestors
should be changed to SourceCode#getAncestors(node)
. See https://eslint.org/docs/latest/extend/custom-rules for the already deprecated items which are being dropped in ESLint 9.
Heads up that the above link sends us to the older docs (at this time). Maybe this link instead? https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getancestors()
Sure, I just meant the older docs for the fact that it had already been deprecated and a replacement was indicated there too. But yours is presumably even more current.
Just one more note that the above example code does work for eslint v8. So, may be helpful for anyone wanting to use flat config in V8.
+1 to this support
eslint v9 has just been released and support for v9 would be greatly appreciated
I'll try to find time to implement this if no-one beats me to it :+1:
FYI. The rules that I had to disable to have eslint succeed are:
"promise/no-return-wrap": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-nesting": "warn",
"promise/no-callback-in-promise": "warn",
Hi guys, are there any plans to support flat config?
Hi guys, are there any plans to support flat config?
Yes, just not a definite timeline
the package also need type declaration for the export in flat config
It's possible to make the current version of the promise plugin work in an ESLint v9 flag configuration file using @eslint/compat
by following these instructions.
In my case I made these changes to eslint.config.js
import { FlatCompat } from '@eslint/eslintrc'
import { fixupConfigRules } from '@eslint/compat'
const compat = new FlatCompat()
export default [
/*
To make the promise plugin work with ESLint v9 we have to use
1. fixupConfigRules to fix obsolete rules API usages
2. FlatCompat to convert the plugin's config format to the v9 flat format
*/
...fixupConfigRules(
compat.config({
extends: ['plugin:promise/recommended'],
ignorePatterns: ['tests/e2e']
})
),
// other config objects
]
:tada: This issue has been resolved in version 6.4.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Thank you!
Description
Please add support for ESLint 9, including Flat config support.
See:
Thanks!