Skip to content

Commit

Permalink
chore: Use eslint configuration from FEC (RedHatInsights#1908)
Browse files Browse the repository at this point in the history
(no jira)

This removes the old eslint configuration and replaces it with the one from https://github.com/RedHatInsights/frontend-starter-app so that Inventory is aligned with other apps in terms of linting and also using the latest custom rules provided by platform.
  • Loading branch information
gkarat authored Jun 27, 2023
1 parent 9a15c65 commit 752fb05
Show file tree
Hide file tree
Showing 234 changed files with 38,064 additions and 29,751 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src/demoData/*
node_modules/*
static/*
dist/*
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
extends: [
'@redhat-cloud-services/eslint-config-redhat-cloud-services',
'plugin:cypress/recommended',
],
globals: {
insights: 'readonly',
shallow: 'readonly',
render: 'readonly',
mount: 'readonly',
IS_DEV: 'readonly',
},
rules: {
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
},
};
113 changes: 0 additions & 113 deletions .eslintrc.yml

This file was deleted.

178 changes: 90 additions & 88 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,109 +1,111 @@
/* global module, __dirname */
require.extensions['.css'] = () => undefined;
const path = require('path');
const glob = require('glob');

const mapper = {
TextVariants: 'Text',
DropdownPosition: 'dropdownConstants',
EmptyStateVariant: 'EmptyState',
TextListItemVariants: 'TextListItem',
TextListVariants: 'TextList',
getDefaultOUIAId: 'ouia',
useOUIAProps: 'ouia',
PaginationVariant: 'Pagination'
TextVariants: 'Text',
DropdownPosition: 'dropdownConstants',
EmptyStateVariant: 'EmptyState',
TextListItemVariants: 'TextListItem',
TextListVariants: 'TextList',
getDefaultOUIAId: 'ouia',
useOUIAProps: 'ouia',
PaginationVariant: 'Pagination',
};

const FECMapper = {
SkeletonSize: 'Skeleton',
PageHeaderTitle: 'PageHeader'
SkeletonSize: 'Skeleton',
PageHeaderTitle: 'PageHeader',
};

const NotificationMapper = {
REMOVE_NOTIFICATION: 'actionTypes',
ADD_NOTIFICATION: 'actionTypes',
NotificationsPortal: 'NotificationPortal/index',
addNotification: 'actions'
REMOVE_NOTIFICATION: 'actionTypes',
ADD_NOTIFICATION: 'actionTypes',
NotificationsPortal: 'NotificationPortal/index',
addNotification: 'actions',
};

const IconMapper = {
AnsibeTowerIcon: 'ansibeTower-icon',
ChartSpikeIcon: 'chartSpike-icon'
AnsibeTowerIcon: 'ansibeTower-icon',
ChartSpikeIcon: 'chartSpike-icon',
};

module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: '> 0.25%, not dead'
}
],
'@babel/react'
presets: [
[
'@babel/preset-env',
{
targets: '> 0.25%, not dead',
},
],
'@babel/react',
],
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
],
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
[
'transform-imports',
{
'@redhat-cloud-services/frontend-components-notifications': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components-notifications/${
NotificationMapper[importName] || importName
}.js`,
preventFullImport: true,
},
'@redhat-cloud-services/frontend-components': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components/${
FECMapper[importName] || importName
}`,
preventFullImport: true,
skipDefaultConversion: true,
},
'@patternfly/react-icons': {
transform: (importName) =>
`@patternfly/react-icons/dist/esm/icons/${
IconMapper[importName] ||
importName
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase()
}.js`,
preventFullImport: true,
},
'@patternfly/react-core': {
transform: (importName) => {
const files = glob.sync(
path.resolve(
__dirname,
`./node_modules/@patternfly/react-core/dist/esm/**/${
mapper[importName] || importName
}.js`
)
);
if (files.length > 0) {
return files[0].replace(/.*(?=@patternfly)/, '');
} else {
throw `File with importName ${importName} does not exist`;
}
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
[
'transform-imports',
{
'@redhat-cloud-services/frontend-components-notifications': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components-notifications/${
NotificationMapper[importName] || importName
}.js`,
preventFullImport: true
},
'@redhat-cloud-services/frontend-components': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components/${FECMapper[importName] || importName}`,
preventFullImport: true,
skipDefaultConversion: true
},
'@patternfly/react-icons': {
transform: (importName) =>
`@patternfly/react-icons/dist/esm/icons/${IconMapper[importName] || importName
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase()}.js`,
preventFullImport: true
},
'@patternfly/react-core': {
transform: (importName) => {
const files = glob.sync(
path.resolve(
__dirname,
`./node_modules/@patternfly/react-core/dist/esm/**/${mapper[
importName
] || importName}.js`
)
);
if (files.length > 0) {
return files[0].replace(/.*(?=@patternfly)/, '');
} else {
throw `File with importName ${importName} does not exist`;
}
},
preventFullImport: false,
skipDefaultConversion: true
}
},
'frontend-notifications'
]
},
preventFullImport: false,
skipDefaultConversion: true,
},
},
'frontend-notifications',
],
env: {
componentTest: {
plugins: [
'istanbul'
]
}
}
],
env: {
componentTest: {
plugins: ['istanbul'],
},
},
};
12 changes: 5 additions & 7 deletions config/customPDF.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* global module */

module.exports = {
Text: () => '',
View: () => '',
StyleSheet: {
create: () => ''
}
Text: () => '',
View: () => '',
StyleSheet: {
create: () => '',
},
};
Loading

0 comments on commit 752fb05

Please sign in to comment.