- Set the browser target to ES6 and reduce the JS bundle size considerably

- Upgrade ESLint to v9.x and migrate the .eslintrc.js file to make it work
This commit is contained in:
Aditya Toshniwal
2024-07-04 18:25:47 +05:30
committed by GitHub
parent 10b2e91e29
commit dcfef154ce
21 changed files with 266 additions and 233 deletions

View File

@@ -6,98 +6,122 @@
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
const globals = require('globals');
const js = require('@eslint/js');
const reactjs = require('eslint-plugin-react');
const jest = require('eslint-plugin-jest');
const babel = require('@babel/eslint-plugin');
const babelParser = require('@babel/eslint-parser');
const ts = require('typescript-eslint');
module.exports = {
'env': {
'browser': true,
'es6': true,
'amd': true,
module.exports = [
{
ignores: [
'**/generated',
'**/node_modules',
'**/vendor',
'**/templates/',
'**/templates\\',
'**/ycache',
'**/regression/htmlcov',
],
},
'extends': [
'eslint:recommended',
'plugin:react/recommended',
/* Uncomment the below line to use linter error for React Hooks.
By Default commented so that builds are generated successfully.
Once all the errors will be resolved will uncomment it and commit it.
*/
// "plugin:react-hooks/recommended",
],
'parser': '@babel/eslint-parser',
'parserOptions': {
'requireConfigFile': false,
'ecmaVersion': 2018,
'ecmaFeatures': {
'jsx': true,
js.configs.recommended,
{
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
languageOptions: {
'parser': babelParser,
ecmaVersion: 2018,
parserOptions: {
'ecmaFeatures': {
'jsx': true,
},
'requireConfigFile': false,
'babelOptions': {
'plugins': [
'@babel/plugin-syntax-jsx',
'@babel/plugin-proposal-class-properties',
],
},
},
'sourceType': 'module',
globals: {
...globals.browser,
...globals.es2017,
...globals.amd,
'_': 'readonly',
'module': 'readonly',
'__dirname': 'readonly',
'global': 'readonly',
'jest': 'readonly',
'process': 'readonly',
},
},
'sourceType': 'module',
'babelOptions': {
'plugins': [
'@babel/plugin-syntax-jsx',
'@babel/plugin-proposal-class-properties',
'plugins': {
'react': reactjs,
'@babel': babel,
},
'rules': {
'indent': [
'error',
2,
],
},
},
'plugins': [
'react',
'@babel',
'jest'
],
'overrides': [
{
'files': ['**/*.{ts,tsx}'],
'plugins': [
'@typescript-eslint',
'linebreak-style': 0,
'quotes': [
'error',
'single',
],
'extends': ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/eslint-recommended'],
'parser': '@typescript-eslint/parser',
'rules': {
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-this-alias': ['off'],
}
'semi': [
'error',
'always',
],
'comma-dangle': [
'error',
'only-multiline',
],
'no-console': ['error', { allow: ['warn', 'error'] }],
// We need to exclude below for RegEx case
'no-useless-escape': 'off',
'no-prototype-builtins': 'off',
'no-global-assign': 'off',
'no-import-assign': 'off',
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'error'
},
{
'files': ['**/*{spec,test}.{js,jsx}', './regression/javascript/**/*.{js}'],
'extends': ['eslint:recommended'],
'env': {
'jest': true
}
},
],
'globals': {
'_': true,
'module': true,
'__dirname': true,
'global': true,
'jest': true
},
'rules': {
'indent': [
'error',
2,
],
'linebreak-style': 0,
'quotes': [
'error',
'single',
],
'semi': [
'error',
'always',
],
'comma-dangle': [
'error',
'only-multiline',
],
'no-console': ['error', { allow: ['warn', 'error'] }],
// We need to exclude below for RegEx case
'no-useless-escape': 0,
'no-prototype-builtins': 0,
'no-global-assign': 0,
'no-import-assign': 0,
},
'settings': {
'react': {
'version': 'detect',
'settings': {
'react': {
'version': 'detect',
},
},
},
};
{
'files': ['**/*.{ts,tsx}'],
languageOptions: {
'parser': ts.parser,
},
'plugins': {
'@typescript-eslint': ts.plugin,
},
'rules': {
'no-unused-vars': 'off',
'no-undef': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-this-alias': ['off'],
}
},
{
'files': ['**/*{spec,test}.{js,jsx}', './regression/javascript/**/*.{js}'],
...jest.configs['flat/recommended'],
rules: {
...jest.configs['flat/recommended'].rules,
'jest/prefer-expect-assertions': 'off',
'jest/expect-expect': 'off',
'jest/no-identical-title': 'off',
'jest/no-done-callback': 'off',
'jest/no-conditional-expect': 'off',
'jest/valid-title': 'off',
},
}
];