Is there any way to make the eslint-webpack-plugin support the latest eslint.config.js configuration file?
webpack.config.js
const path = require('path')
const ESLintPlugin = require('eslint-webpack-plugin')
module.exports = {
entry: path.join(__dirname, '../src/index.js'),
output: {
filename: 'static/js/[name].js',
path: path.join(__dirname, '../dist')
},
module: {
rules: [
{
include: [path.resolve(__dirname, '../src')],
test: /.(js|ts|tsx)$/,
use: ['babel-loader']
}
]
},
resolve: {
modules: ['node_modules'],
extensions: ['.js', '.tsx', '.ts'],
alias: {
'@': path.join(__dirname, '../src')
}
},
plugins: [
new ESLintPlugin({
extensions: ['js, ts, tsx']
})
]
}
eslint.config.js
const eslint = require('@eslint/js');
const typeScriptEsLintPlugin = require('@typescript-eslint/eslint-plugin');
const { FlatCompat } = require('@eslint/eslintrc');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: typeScriptEsLintPlugin.configs['recommended']
});
module.exports = [
eslint.configs.recommended,
...compat.config({
root: true,
env: { browser: true, node: true },
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
globals: {
module: true,
__dirname: true,
require: true
},
rules: {
'curly': 'error',
'comma-dangle': 'error',
'no-unneeded-ternary': 'error',
'no-empty-function': 'error',
'eqeqeq': 'error',// Use === and !== instead of == and !=
'no-else-return': 'error',
'no-var': 'error', // Use let or const
'indent': ['error', 2, { 'SwitchCase': 1 }],
'func-style': ['error', 'expression'],
'key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'strict' }],
'keyword-spacing': ['error', { before: true, after: true }],
'no-duplicate-imports': 'error',
'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0 }],
'no-lonely-if': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'no-multi-assign': 'error',
'no-empty-character-class': 'error',
'arrow-spacing': 'error',
'require-await': 'error',
'block-spacing': 'error',
'array-bracket-spacing': ['error', 'never'],
'computed-property-spacing': ['error', 'never'],
'func-call-spacing': ['error', 'never'],
'lines-between-class-members': ['error', 'always', { 'exceptAfterSingleLine': true }],
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'no-whitespace-before-property': 'error',
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
'spaced-comment': ['error', 'always'],
'space-before-blocks': 'error',
'space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always' }],
'space-in-parens': ['error', 'never'],
'switch-colon-spacing': ['error', { before: false, after: true }],
'template-curly-spacing': ['error', 'never'],
'wrap-iife': ['error', 'inside', { functionPrototypeMethods: true }],
'dot-location': ['error', 'object'],
'no-prototype-builtins': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-var-requires': 'off'
}
})
];
my typescript file
const x = 1; // x' is never reassigned. Use 'const' instead.eslint(no-param-reassign)
function foo() { // Expected a function expression.eslint(func-style)
}
and the terminal output :
ERROR in [eslint] No ESLint configuration found in C:tempeslinttestsrc.
If I use the .eslintrc.js configuration file, a very, very long string of error messages appears, which cannot be fully displayed in the terminal. I think this might be a version conflict
taotao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.