Rewrite .eslintrc.es5.js to new config format

[MAILPOET-5015]
This commit is contained in:
Jan Jakes
2023-03-23 14:46:40 +01:00
committed by Jan Jakeš
parent c7c06d0a21
commit d37292ff13
4 changed files with 55 additions and 27 deletions

11
mailpoet/eslint.config.js Normal file
View File

@ -0,0 +1,11 @@
const es5Config = require('@mailpoet/eslint-config/eslint-es5.config');
module.exports = [
{
ignores: ['assets/js/src/vendor/**'],
},
...es5Config.map((config) => ({
...config,
files: ['assets/js/src/**/*.js'],
})),
];

View File

@ -4,11 +4,10 @@
"extends @wordpress/browserslist-config"
],
"scripts": {
"lint": "pnpm run lint6 && pnpm run lint-ts && pnpm run lint5 && pnpm run lint-tests",
"lint6": "eslint -c ../packages/js/eslint-config/.eslintrc.es6.js --max-warnings 0 'assets/js/src/**/*.jsx' 'tests/javascript/**/*.js'",
"lint-ts": "eslint -c ../packages/js/eslint-config/.eslintrc.ts.js --max-warnings 0 'assets/js/src/**/*.tsx' 'assets/js/src/**/*.ts'",
"lint5": "eslint -c ../packages/js/eslint-config/.eslintrc.es5.js --max-warnings 0 'assets/js/src/**/*.js' 'webpack.config.js'",
"lint-tests": "eslint -c ../packages/js/eslint-config/.eslintrc.tests_newsletter_editor.js --max-warnings 0 'tests/javascript_newsletter_editor'",
"lint": "eslint --max-warnings 0 'assets/js/src/**' && pnpm run lint6 && pnpm run lint-ts && pnpm run lint-tests",
"lint6": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.es6.js --max-warnings 0 'assets/js/src/**/*.jsx' 'tests/javascript/**/*.js'",
"lint-ts": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.ts.js --max-warnings 0 'assets/js/src/**/*.tsx' 'assets/js/src/**/*.ts'",
"lint-tests": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.tests_newsletter_editor.js --max-warnings 0 'tests/javascript_newsletter_editor'",
"autoprefixer": "postcss assets/dist/css/*.css --use autoprefixer --no-map --replace",
"scss": "sass assets/css/src/:assets/dist/css/ --style compressed",
"stylelint": "stylelint --fix",
@ -22,10 +21,10 @@
},
"lint-staged": {
"*.{scss,css}": "pnpm run stylelint",
"!(*spec).js": "eslint -c ../packages/js/eslint-config/.eslintrc.es5.js --max-warnings 0",
"*.jsx": "eslint -c ../packages/js/eslint-config/.eslintrc.es6.js --max-warnings 0",
"*.{tsx,ts}": "eslint -c ../packages/js/eslint-config/.eslintrc.ts.js --max-warnings 0",
"**/newsletter_editor/**/*spec.js": "eslint -c ../packages/js/eslint-config/.eslintrc.tests_newsletter_editor.js --max-warnings 0",
"!(*spec).js": "eslint --max-warnings 0",
"*.jsx": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.es6.js --max-warnings 0",
"*.{tsx,ts}": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.ts.js --max-warnings 0",
"**/newsletter_editor/**/*spec.js": "ESLINT_USE_FLAT_CONFIG=false eslint -c ../packages/js/eslint-config/.eslintrc.tests_newsletter_editor.js --max-warnings 0",
"*.php": [
"phplint",
"./do qa:code-sniffer",

View File

@ -1,18 +0,0 @@
module.exports = {
extends: ['airbnb/legacy', 'prettier'],
env: {
amd: true,
browser: true,
},
plugins: ['eslint-plugin-import'],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
rules: {
'import/prefer-default-export': 0, // we want to stop using default exports and start using named exports
'no-underscore-dangle': 0, // Backbone uses underscores, we cannot remove them
'import/no-default-export': 1, // no default exports
},
};

View File

@ -0,0 +1,36 @@
const babelParser = require('@babel/eslint-parser');
const FlatCompat = require('@eslint/eslintrc').FlatCompat;
const airbnbLegacyConfig = require('eslint-config-airbnb/legacy');
const prettierConfig = require('eslint-config-prettier');
const importPlugin = require('eslint-plugin-import');
const globals = require('globals');
// compat configs
const compat = new FlatCompat({ baseDirectory: __dirname });
const airbnbLegacyCompatConfig = compat.config(airbnbLegacyConfig);
const prettierCompatConfig = compat.config(prettierConfig);
module.exports = [
...airbnbLegacyCompatConfig,
...prettierCompatConfig,
{
languageOptions: {
parser: babelParser,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
globals: {
...globals.browser,
},
},
plugins: {
import: importPlugin,
},
rules: {
'import/prefer-default-export': 0, // we want to stop using default exports and start using named exports
'no-underscore-dangle': 0, // Backbone uses underscores, we cannot remove them
'import/no-default-export': 1, // no default exports
},
},
];