From 738cc3b1957920dba812e470dc589b2fb1da53e0 Mon Sep 17 00:00:00 2001 From: Alberto Gutierrez Date: Thu, 15 Feb 2018 18:14:51 +0100 Subject: [PATCH] fix(constants file): Rename all constants file to {Component_Name}Constants --- CONTRIBUTING.md | 1 + src/components/Alert/Alert.js | 2 +- src/components/Alert/Alert.stories.js | 2 +- src/components/Alert/Alert.test.js | 2 +- src/components/Alert/{constants.js => AlertConstants.js} | 0 src/components/Alert/helpers.js | 2 +- src/components/Alert/helpers.test.js | 2 +- src/components/Button/Button.js | 2 +- src/components/Button/Button.stories.js | 2 +- src/components/Button/{constants.js => ButtonConstants.js} | 0 src/components/Button/DropdownButton.js | 2 +- src/components/Button/SplitButton.js | 2 +- src/components/Chart/AreaChart.js | 2 +- src/components/Chart/BarChart.js | 2 +- src/components/Chart/{constants.js => ChartConstants.js} | 0 src/components/Chart/DonutChart.js | 2 +- src/components/Chart/GroupedBarChart.js | 2 +- src/components/Chart/LineChart.js | 2 +- src/components/Chart/PieChart.js | 2 +- src/components/Chart/SingleAreaChart.js | 2 +- src/components/Chart/SingleLineChart.js | 2 +- src/components/Chart/SparklineChart.js | 2 +- src/components/Chart/StackedBarChart.js | 2 +- .../Pagination/{constants.js => PaginationConstants.js} | 0 src/components/Pagination/PaginationRow.js | 2 +- src/components/Pagination/Paginator.js | 2 +- src/components/Pagination/index.js | 2 +- src/components/Table/TableCell.js | 2 +- src/components/Table/{constants.js => TableConstants.js} | 0 src/components/Table/TableHeading.js | 2 +- src/components/Table/index.js | 2 +- src/components/VerticalNav/VerticalNav.js | 4 ++-- .../VerticalNav/{constants.js => VerticalNavConstants.js} | 0 src/components/VerticalNav/VerticalNavItem.js | 6 +++++- src/components/VerticalNav/VerticalNavItemHelper.js | 2 +- src/components/VerticalNav/VerticalNavMasthead.js | 2 +- src/components/VerticalNav/VerticalNavSecondaryItem.js | 6 +++++- src/components/VerticalNav/VerticalNavTertiaryItem.js | 6 +++++- 38 files changed, 45 insertions(+), 32 deletions(-) rename src/components/Alert/{constants.js => AlertConstants.js} (100%) rename src/components/Button/{constants.js => ButtonConstants.js} (100%) rename src/components/Chart/{constants.js => ChartConstants.js} (100%) rename src/components/Pagination/{constants.js => PaginationConstants.js} (100%) rename src/components/Table/{constants.js => TableConstants.js} (100%) rename src/components/VerticalNav/{constants.js => VerticalNavConstants.js} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e02c5ac8805..a5c71845f10 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,7 @@ when possible and accept [props](https://facebook.github.io/react/docs/component ### Code Consistency * All files and folders under `src/components` should name with PascalCase except `index.js` files +* If you need a constant file, it should be called `{Component_Name}Constants.js` (Component_Name with PascalCase) * Each component should treat as a standalone package and live under its own folder * Single file per component with **default export** * When component is a set of components (e.g., ListGroup and ListGroupItem), diff --git a/src/components/Alert/Alert.js b/src/components/Alert/Alert.js index 49bec07c568..5b616ebc698 100644 --- a/src/components/Alert/Alert.js +++ b/src/components/Alert/Alert.js @@ -8,7 +8,7 @@ import { ALERT_TYPES, DEPRECATED_ALERT_TYPES, ALERT_TYPE_ERROR -} from './constants'; +} from './AlertConstants'; /** * Alert Component for Patternfly React diff --git a/src/components/Alert/Alert.stories.js b/src/components/Alert/Alert.stories.js index d26fe86b306..cf577f4b546 100644 --- a/src/components/Alert/Alert.stories.js +++ b/src/components/Alert/Alert.stories.js @@ -4,7 +4,7 @@ import { action } from '@storybook/addon-actions'; import { withKnobs, text, select } from '@storybook/addon-knobs'; import { defaultTemplate } from '../../../storybook/decorators/storyTemplates'; import { DOCUMENTATION_URL } from '../../../storybook/constants'; -import { ALERT_TYPES } from './constants'; +import { ALERT_TYPES } from './AlertConstants'; import { Alert } from './index'; const stories = storiesOf('Alert', module); diff --git a/src/components/Alert/Alert.test.js b/src/components/Alert/Alert.test.js index 60b1a23b317..691348263c1 100644 --- a/src/components/Alert/Alert.test.js +++ b/src/components/Alert/Alert.test.js @@ -3,7 +3,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; import Alert from './Alert'; -import { ALERT_TYPES, DEPRECATED_ALERT_TYPES } from './constants'; +import { ALERT_TYPES, DEPRECATED_ALERT_TYPES } from './AlertConstants'; const ALL_ALERT_TYPES = [...ALERT_TYPES, ...DEPRECATED_ALERT_TYPES]; diff --git a/src/components/Alert/constants.js b/src/components/Alert/AlertConstants.js similarity index 100% rename from src/components/Alert/constants.js rename to src/components/Alert/AlertConstants.js diff --git a/src/components/Alert/helpers.js b/src/components/Alert/helpers.js index a735ac50d7a..56c84eb2683 100644 --- a/src/components/Alert/helpers.js +++ b/src/components/Alert/helpers.js @@ -4,7 +4,7 @@ import { ALERT_TYPE_WARNING, ALERT_TYPE_SUCCESS, ALERT_TYPE_INFO -} from './constants'; +} from './AlertConstants'; export const warnIfDeprecatedType = type => { if (type === ALERT_TYPE_DANGER) { diff --git a/src/components/Alert/helpers.test.js b/src/components/Alert/helpers.test.js index 825c224767d..e006df1ea9e 100644 --- a/src/components/Alert/helpers.test.js +++ b/src/components/Alert/helpers.test.js @@ -1,5 +1,5 @@ import { warnIfDeprecatedType, getIconName, getClassName } from './helpers'; -import { ALERT_TYPES, DEPRECATED_ALERT_TYPES } from './constants'; +import { ALERT_TYPES, DEPRECATED_ALERT_TYPES } from './AlertConstants'; const ALL_ALERT_TYPES = [...ALERT_TYPES, ...DEPRECATED_ALERT_TYPES]; diff --git a/src/components/Button/Button.js b/src/components/Button/Button.js index 9344a3fb8f0..9ad7e1a3db8 100644 --- a/src/components/Button/Button.js +++ b/src/components/Button/Button.js @@ -1,7 +1,7 @@ import { Button as BsButton } from 'react-bootstrap'; import React from 'react'; import PropTypes from 'prop-types'; -import { BUTTON_BS_STYLES } from './constants'; +import { BUTTON_BS_STYLES } from './ButtonConstants'; const Button = props => ; diff --git a/src/components/Button/Button.stories.js b/src/components/Button/Button.stories.js index 9d486134cb5..eb9798dc909 100644 --- a/src/components/Button/Button.stories.js +++ b/src/components/Button/Button.stories.js @@ -6,7 +6,7 @@ import { inlineTemplate } from '../../../storybook/decorators/storyTemplates'; import { DOCUMENTATION_URL } from '../../../storybook/constants'; import { Grid, Row, Col, MenuItem } from '../../index'; import { Button, ButtonGroup, DropdownButton, SplitButton } from './index'; -import { BUTTON_BS_STYLES } from './constants'; +import { BUTTON_BS_STYLES } from './ButtonConstants'; const stories = storiesOf('Button', module); diff --git a/src/components/Button/constants.js b/src/components/Button/ButtonConstants.js similarity index 100% rename from src/components/Button/constants.js rename to src/components/Button/ButtonConstants.js diff --git a/src/components/Button/DropdownButton.js b/src/components/Button/DropdownButton.js index c4dcd59583a..ddf3fe74a12 100644 --- a/src/components/Button/DropdownButton.js +++ b/src/components/Button/DropdownButton.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { DropdownButton as BsDropdownButton } from 'react-bootstrap'; -import { BUTTON_BS_STYLES } from './constants'; +import { BUTTON_BS_STYLES } from './ButtonConstants'; const DropdownButton = props => ; diff --git a/src/components/Button/SplitButton.js b/src/components/Button/SplitButton.js index 59a8c64ea31..6cb2c0556ae 100644 --- a/src/components/Button/SplitButton.js +++ b/src/components/Button/SplitButton.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { SplitButton as BsSplitButton } from 'react-bootstrap'; -import { BUTTON_BS_STYLES } from './constants'; +import { BUTTON_BS_STYLES } from './ButtonConstants'; const SplitButton = props => ; diff --git a/src/components/Chart/AreaChart.js b/src/components/Chart/AreaChart.js index eae9deb2f6e..d9ed007ed52 100644 --- a/src/components/Chart/AreaChart.js +++ b/src/components/Chart/AreaChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const AreaChart = getComposer('AREA_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/BarChart.js b/src/components/Chart/BarChart.js index 8e0546faf44..db6b86c3914 100644 --- a/src/components/Chart/BarChart.js +++ b/src/components/Chart/BarChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; import { compose, mapProps } from 'recompose'; import { c3ChartDefaults } from '../../common/patternfly'; diff --git a/src/components/Chart/constants.js b/src/components/Chart/ChartConstants.js similarity index 100% rename from src/components/Chart/constants.js rename to src/components/Chart/ChartConstants.js diff --git a/src/components/Chart/DonutChart.js b/src/components/Chart/DonutChart.js index ddacb68c51f..764fde85476 100644 --- a/src/components/Chart/DonutChart.js +++ b/src/components/Chart/DonutChart.js @@ -4,7 +4,7 @@ import { findDOMNode } from 'react-dom'; import { lifecycle, compose } from 'recompose'; import { patternfly } from '../../common/patternfly'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const pfSetDonutChartTitle = patternfly.pfSetDonutChartTitle; const colIndexOfMaxValue = columns => { diff --git a/src/components/Chart/GroupedBarChart.js b/src/components/Chart/GroupedBarChart.js index 73280dd8767..9addcc571a8 100644 --- a/src/components/Chart/GroupedBarChart.js +++ b/src/components/Chart/GroupedBarChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const GroupedBarChart = getComposer('GROUPED_BAR_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/LineChart.js b/src/components/Chart/LineChart.js index 40b418eec66..065e2c050a8 100644 --- a/src/components/Chart/LineChart.js +++ b/src/components/Chart/LineChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const LineChart = getComposer('LINE_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/PieChart.js b/src/components/Chart/PieChart.js index bd2314e563b..dd51290a151 100644 --- a/src/components/Chart/PieChart.js +++ b/src/components/Chart/PieChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const PieChart = getComposer('PIE_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/SingleAreaChart.js b/src/components/Chart/SingleAreaChart.js index 0f238f06abb..294795bea28 100644 --- a/src/components/Chart/SingleAreaChart.js +++ b/src/components/Chart/SingleAreaChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const SingleAreaChart = getComposer('SINGLE_AREA_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/SingleLineChart.js b/src/components/Chart/SingleLineChart.js index 370c1b13c96..d6c2d61b6cc 100644 --- a/src/components/Chart/SingleLineChart.js +++ b/src/components/Chart/SingleLineChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const SingleLineChart = getComposer('SINGLE_LINE_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/SparklineChart.js b/src/components/Chart/SparklineChart.js index e35308d1454..ec7d6882d37 100644 --- a/src/components/Chart/SparklineChart.js +++ b/src/components/Chart/SparklineChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const SparklineChart = getComposer('SPARKLINE_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Chart/StackedBarChart.js b/src/components/Chart/StackedBarChart.js index ffe0e899e72..9a5932b46e1 100644 --- a/src/components/Chart/StackedBarChart.js +++ b/src/components/Chart/StackedBarChart.js @@ -1,6 +1,6 @@ import React from 'react'; import C3Chart from 'react-c3js'; -import { getComposer } from './constants'; +import { getComposer } from './ChartConstants'; const StackedBarChart = getComposer('STACKED_BAR_CHART')( ({ className, type, data, ...props }) => ( diff --git a/src/components/Pagination/constants.js b/src/components/Pagination/PaginationConstants.js similarity index 100% rename from src/components/Pagination/constants.js rename to src/components/Pagination/PaginationConstants.js diff --git a/src/components/Pagination/PaginationRow.js b/src/components/Pagination/PaginationRow.js index 96f23441a1b..4038f84ec40 100644 --- a/src/components/Pagination/PaginationRow.js +++ b/src/components/Pagination/PaginationRow.js @@ -7,7 +7,7 @@ import PaginationRowItems from './PaginationRowItems'; import PaginationRowBack from './PaginationRowBack'; import PaginationRowForward from './PaginationRowForward'; import { noop } from '../../common/helpers'; -import { PAGINATION_VIEW_TYPES, PAGINATION_VIEW } from './constants'; +import { PAGINATION_VIEW_TYPES, PAGINATION_VIEW } from './PaginationConstants'; import { Form, FormControl, FormGroup, ControlLabel } from '../Form'; import { DropdownButton } from '../Button'; import { MenuItem } from '../MenuItem'; diff --git a/src/components/Pagination/Paginator.js b/src/components/Pagination/Paginator.js index 77f6f5a4023..289020c1295 100644 --- a/src/components/Pagination/Paginator.js +++ b/src/components/Pagination/Paginator.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import PaginationRow from './PaginationRow'; import { bindMethods, noop } from '../../common/helpers'; -import { PAGINATION_VIEW_TYPES } from './constants'; +import { PAGINATION_VIEW_TYPES } from './PaginationConstants'; class Paginator extends React.Component { constructor(props) { diff --git a/src/components/Pagination/index.js b/src/components/Pagination/index.js index a01045aa944..59e78e1eb9a 100644 --- a/src/components/Pagination/index.js +++ b/src/components/Pagination/index.js @@ -1,5 +1,5 @@ import paginate from './paginate'; -import { PAGINATION_VIEW, PAGINATION_VIEW_TYPES } from './constants'; +import { PAGINATION_VIEW, PAGINATION_VIEW_TYPES } from './PaginationConstants'; import Paginator from './Paginator'; import PaginationRow from './PaginationRow'; import PaginationRowAmountOfPages from './PaginationRowAmountOfPages'; diff --git a/src/components/Table/TableCell.js b/src/components/Table/TableCell.js index 25f5b059083..ef09f89f81f 100644 --- a/src/components/Table/TableCell.js +++ b/src/components/Table/TableCell.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; -import { TABLE_ALIGN, TABLE_ALIGNMENT_TYPES } from './constants'; +import { TABLE_ALIGN, TABLE_ALIGNMENT_TYPES } from './TableConstants'; /** * TableCell component for Patternfly React */ diff --git a/src/components/Table/constants.js b/src/components/Table/TableConstants.js similarity index 100% rename from src/components/Table/constants.js rename to src/components/Table/TableConstants.js diff --git a/src/components/Table/TableHeading.js b/src/components/Table/TableHeading.js index 332e815b2f5..d8995cfad4d 100644 --- a/src/components/Table/TableHeading.js +++ b/src/components/Table/TableHeading.js @@ -6,7 +6,7 @@ import { TABLE_ALIGNMENT_TYPES, TABLE_SORT_DIRECTION, TABLE_SORT_DIRECTIONS -} from './constants'; +} from './TableConstants'; /** * TableHeading component for Patternfly React diff --git a/src/components/Table/index.js b/src/components/Table/index.js index 38bba568ec1..461cbeccac8 100644 --- a/src/components/Table/index.js +++ b/src/components/Table/index.js @@ -12,7 +12,7 @@ import { TABLE_ALIGNMENT_TYPES, TABLE_SORT_DIRECTION, TABLE_SORT_DIRECTIONS -} from './constants'; +} from './TableConstants'; import TableActions from './TableActions'; import TableButton from './TableButton'; import TableCell from './TableCell'; diff --git a/src/components/VerticalNav/VerticalNav.js b/src/components/VerticalNav/VerticalNav.js index 5d23726166b..800f09a4801 100644 --- a/src/components/VerticalNav/VerticalNav.js +++ b/src/components/VerticalNav/VerticalNav.js @@ -20,7 +20,7 @@ import { addBodyEventListener, removeBodyEventListener, setBodyClassIf -} from './constants'; +} from './VerticalNavConstants'; import VerticalNavSecondaryItem from './VerticalNavSecondaryItem'; import VerticalNavTertiaryItem from './VerticalNavTertiaryItem'; @@ -100,7 +100,7 @@ class BaseVerticalNav extends React.Component { updateBodyClasses() { // Note: Updating the body element classes from here like this is a hacky, non-react-y pattern. - // It's only here for consistency. See comments on getBodyContentElement in ./constants.js. + // It's only here for consistency. See comments on getBodyContentElement in ./VerticalNavConstants.js. const { dynamicBodyClasses, navCollapsed, diff --git a/src/components/VerticalNav/constants.js b/src/components/VerticalNav/VerticalNavConstants.js similarity index 100% rename from src/components/VerticalNav/constants.js rename to src/components/VerticalNav/VerticalNavConstants.js diff --git a/src/components/VerticalNav/VerticalNavItem.js b/src/components/VerticalNav/VerticalNavItem.js index 4a5a13e99e3..bcbbef854fa 100644 --- a/src/components/VerticalNav/VerticalNavItem.js +++ b/src/components/VerticalNav/VerticalNavItem.js @@ -1,6 +1,10 @@ import React from 'react'; import { getContext } from 'recompose'; -import { wrongDepth, correctDepth, navContextTypes } from './constants'; +import { + wrongDepth, + correctDepth, + navContextTypes +} from './VerticalNavConstants'; import VerticalNavItemHelper from './VerticalNavItemHelper'; /** diff --git a/src/components/VerticalNav/VerticalNavItemHelper.js b/src/components/VerticalNav/VerticalNavItemHelper.js index ad3f9b15ace..20a20b0a6fd 100644 --- a/src/components/VerticalNav/VerticalNavItemHelper.js +++ b/src/components/VerticalNav/VerticalNavItemHelper.js @@ -15,7 +15,7 @@ import { getItemProps, itemObjectTypes, navContextTypes -} from './constants'; +} from './VerticalNavConstants'; class BaseVerticalNavItemHelper extends React.Component { constructor(props) { diff --git a/src/components/VerticalNav/VerticalNavMasthead.js b/src/components/VerticalNav/VerticalNavMasthead.js index 52df52bbada..04fb1ad4930 100644 --- a/src/components/VerticalNav/VerticalNavMasthead.js +++ b/src/components/VerticalNav/VerticalNavMasthead.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { getContext } from 'recompose'; import { Navbar } from 'react-bootstrap'; import VerticalNavBrand from './VerticalNavBrand'; -import { navContextTypes } from './constants'; +import { navContextTypes } from './VerticalNavConstants'; /** * VerticalNavMasthead - the first child of a VerticalNav component diff --git a/src/components/VerticalNav/VerticalNavSecondaryItem.js b/src/components/VerticalNav/VerticalNavSecondaryItem.js index 94395802881..9a1c887fd8c 100644 --- a/src/components/VerticalNav/VerticalNavSecondaryItem.js +++ b/src/components/VerticalNav/VerticalNavSecondaryItem.js @@ -1,6 +1,10 @@ import React from 'react'; import { getContext } from 'recompose'; -import { wrongDepth, correctDepth, navContextTypes } from './constants'; +import { + wrongDepth, + correctDepth, + navContextTypes +} from './VerticalNavConstants'; import VerticalNavItemHelper from './VerticalNavItemHelper'; /** diff --git a/src/components/VerticalNav/VerticalNavTertiaryItem.js b/src/components/VerticalNav/VerticalNavTertiaryItem.js index 0fb2a4c3c30..b269e1f1981 100644 --- a/src/components/VerticalNav/VerticalNavTertiaryItem.js +++ b/src/components/VerticalNav/VerticalNavTertiaryItem.js @@ -1,6 +1,10 @@ import React from 'react'; import { getContext } from 'recompose'; -import { wrongDepth, correctDepth, navContextTypes } from './constants'; +import { + wrongDepth, + correctDepth, + navContextTypes +} from './VerticalNavConstants'; import VerticalNavItemHelper from './VerticalNavItemHelper'; /**