Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",
"import-default-name": [
"error",
{
"classnames": "classNames",
"prop-types": "PropTypes"
}
],
"import/no-extraneous-dependencies": [
"error",
{
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"editor.formatOnSave": true,
"prettier.eslintIntegration": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "none"
"prettier.trailingComma": "none",
"eslint.options": {
"rulePaths": ["./lint-rules"]
}
}
52 changes: 52 additions & 0 deletions lint-rules/import-default-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = {
meta: {
docs: {
description: 'Force default import names to match specified values',
category: 'Possible Errors',
recommended: true
},
fixable: 'code',
schema: [
{
type: 'object',
properties: {},
additionalProperties: true
}
]
},
create(context) {
const [importMap = {}] = context.options;
return {
ImportDeclaration(node) {
const defaultImport = node.specifiers.find(
spec => spec.type === 'ImportDefaultSpecifier'
);
if (!defaultImport) {
return;
}
const expectedName = importMap[node.source.value];
const receivedName = defaultImport.local.name;
if (expectedName && expectedName !== receivedName) {
context.report({
node,
message:
'Expected default import to be named "{{ expected }}" but received "{{ received }}"',
data: {
expected: expectedName,
received: receivedName
},
fix(fixer) {
const [varDecl] = context.getDeclaredVariables(node);
return [
...varDecl.references.map(ref =>
fixer.replaceText(ref.identifier, expectedName)
),
fixer.replaceText(defaultImport, expectedName)
];
}
});
}
}
};
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"build:scripts": "babel src --out-dir dist/js --ignore .test.js,__mocks__",
"build:less": "mkdir -p dist/less && cp -r less/* dist/less",
"build:sass": "mkdir -p dist/sass && cp -r sass/patternfly-react/* dist/sass && node-sass --output-style compressed --include-path sass $npm_package_sassIncludes_patternfly $npm_package_sassIncludes_bootstrap $npm_package_sassIncludes_fontAwesome -o dist/css sass/patternfly-react.scss",
"lint": "eslint --fix --max-warnings 0 src storybook && npm run stylelint",
"lint": "eslint --rulesdir lint-rules/ --fix --max-warnings 0 src storybook && npm run stylelint",
"prettier": "prettier --write --single-quote --trailing-comma=none '{src,storybook}/**/*.js'",
"prepare": "npm run build",
"test": "npm run lint && jest",
Expand Down
1 change: 0 additions & 1 deletion sass/patternfly-react/_patternfly-react.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Patternfly React Partials
*/
@import 'card';

@import 'utilization-bar';
@import 'breadcrumb';
@import 'label-remove';
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {
} from './index';

test('Aggregate Status Card Count is working properly', () => {
const component = mount(
<AggregateStatusCount> 9 </AggregateStatusCount>
);
const component = mount(<AggregateStatusCount> 9 </AggregateStatusCount>);

expect(component.render()).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const AggregateStatusCount = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-aggregate-status-count', className);
const classes = classNames('card-pf-aggregate-status-count', className);

return (
<span className={classes} {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const AggregateStatusNotification = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-aggregate-status-notification',
className
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const AggregateStatusNotifications = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-aggregate-status-notifications',
className
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/Card.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

Expand All @@ -12,7 +12,7 @@ const Card = ({
cardRef,
...props
}) => {
const classes = ClassNames(
const classes = classNames(
'card-pf',
{ 'card-pf-accented': accented },
{ 'card-pf-aggregate-status': aggregated },
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardBody.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const CardBody = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-body', className);
const classes = classNames('card-pf-body', className);

return (
<div className={classes} {...props}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardDropdownButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { Dropdown } from '../Dropdown';
Expand All @@ -12,7 +12,7 @@ const CardDropdownButton = ({
pullRight,
...props
}) => {
const classes = ClassNames('card-pf-time-frame-filter', className);
const classes = classNames('card-pf-time-frame-filter', className);
const CustomButtonGroup = customGroup => (
<ButtonGroup {...customGroup} bsClass=" " />
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardFooter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const CardFooter = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-footer', className);
const classes = classNames('card-pf-footer', className);

return (
<div className={classes} {...props}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardGrid.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import CardHeightMatching from './CardHeightMatching';
import { Grid } from '../Grid/index';

const CardGrid = ({ matchHeight, children, className, ...props }) => {
const classes = ClassNames('container-cards-pf', className);
const classes = classNames('container-cards-pf', className);
const cardSelector = ['.card-pf-match-height'];

if (matchHeight) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardHeading.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const CardHeading = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-heading', className);
const classes = classNames('card-pf-heading', className);

return (
<div className={classes} {...props}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardLink.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const CardLink = ({ disabled, children, className, icon, ...props }) => {
const classes = ClassNames(
const classes = classNames(
{
'card-pf-link-with-icon': icon,
disabled
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardTitle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const CardTitle = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-title', className);
const classes = classNames('card-pf-title', className);

return (
<h2 className={classes} {...props}>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Cards/Cards.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ test('Card Title is working properly', () => {
});

test('Card Footer is working properly', () => {
const component = mount(
<CardFooter>This is a Card Footer</CardFooter>
);
const component = mount(<CardFooter>This is a Card Footer</CardFooter>);

expect(component.render()).toMatchSnapshot();
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/UtilizationTrendCard/UtilizationCard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { Card } from '../index';

const UtilizationCard = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-utilization', className);
const classes = classNames('card-pf-utilization', className);

return (
<Card className={classes} {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const UtilizationCardDetails = ({ children, className, ...props }) => {
const classes = ClassNames('card-pf-utilization-details', className);
const classes = classNames('card-pf-utilization-details', className);

return (
<p className={classes} {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const UtilizationCardDetailsCount = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-utilization-card-details-count',
className
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const UtilizationCardDetailsDesc = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-utilization-card-details-description',
className
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const UtilizationCardDetailsLine1 = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-utilization-card-details-line-1',
className
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ClassNames from 'classnames';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';

const UtilizationCardDetailsLine2 = ({ children, className, ...props }) => {
const classes = ClassNames(
const classes = classNames(
'card-pf-utilization-card-details-line-2',
className
);
Expand Down