Closed vpishuk closed 1 month ago
Could you share you eslitn config and this plugin version?
Here is my eslint config: https://github.com/laverve/utilities/blob/main/packages/eslint-utils/src/eslint.config.js Plugins version that I tried is the latest one. E2lint v9 is using flat format as a default one.
The config didn't use eslint-plugin-i18next
at all. Did you provide the wrong branch of the repo?
It's not there because I haven't figured out how to get flat config from this plugin which is required by eslint v9.
I have figured out how to add it without flat config thanks to modules provided by eslint for backward compatibility. It would be nice to address this issue on plugin level.
Here is my solution:
import eslintJs from "@eslint/js";
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: eslintJs.configs.recommended
});
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
}
return fixupPluginRules(plugin);
}
export const config = [
{
plugins: {
i18next: legacyPlugin("eslint-plugin-i18next", "i18next")
},
rules: {}
}
];
could you try this
import i18next from 'eslint-plugin-i18next';
export default [
{
plugins: { i18next },
rules: {
'i18next/no-literal-string': ['error', { mode: 'all' }],
},
},
];
@edvardchen thank you! This wirks. It would be nice to add it into the docs. It would be great to export sharable config for eslint9.
Let me guess. You mean like this?
// eslint.config.js
import jsdoc from 'eslint-plugin-jsdoc';
export default [
jsdoc.configs['flat/recommended'],
];
Yes, this would be great.
Thie plugin stopped working with ESLint v9.