Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to Carbon eslint configuration #2510

Merged
merged 3 commits into from
Aug 24, 2021
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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": ["wesbos"],
"extends": ["carbon"],
"globals": {
"fathom": "readonly"
},
"root": true,
"rules": {
"react/prop-types": 0,
"react/destructuring-assignment": 0,
Expand Down
8 changes: 1 addition & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"prettier.disableLanguages": ["javascript", "javascriptreact"],
"eslint.lintTask.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
Expand Down
1 change: 0 additions & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/* eslint-disable import/prefer-default-export */
import './src/styles/index.scss';
1 change: 0 additions & 1 deletion gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import React from 'react';
import ogimage from './src/images/ogimage.png';

Expand Down
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
},
"dependencies": {
"@carbon/charts-react": "0.42.1",
"@carbon/elements": "^10.41.0",
"@carbon/icons": "^10.38.0",
"@carbon/icons-react": "^10.38.0",
"@carbon/pictograms": "^11.16.0",
"@carbon/pictograms-react": "^11.16.0",
"@loadable/component": "^5.15.0",
"@slack/web-api": "^5.11.0",
"carbon-components": "^10.42.0",
"carbon-components-react": "^7.42.0",
"@carbon/elements": "^10.41.0",
"@carbon/icons": "^10.38.0",
"@carbon/icons-react": "^10.38.0",
"change-case": "^4.1.1",
"classnames": "^2.2.6",
"codesandbox": "^2.1.10",
Expand Down Expand Up @@ -84,16 +84,8 @@
"babel-preset-gatsby": "^1.7.1",
"d3": "7.0.0",
"dotenv": "^8.2.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-wesbos": "0.0.19",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.1",
"eslint": "^7.32.0",
"eslint-config-carbon": "^2.8.0",
"fs-extra": "^9.0.1",
"gatsby-plugin-lodash": "^4.7.1",
"gatsby-plugin-manifest": "^3.7.1",
Expand Down
4 changes: 1 addition & 3 deletions src/components/ChartIndexPage/ChartIndexListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const ChartIndexListItem = React.memo(
}

return (
<>
<article className="component-index-item">
<article className="component-index-item">
<div className="component-index-item__image">{img}</div>
<div className="component-index-item__content">
<header className="component-index-item__name">{name}</header>
Expand Down Expand Up @@ -67,7 +66,6 @@ const ChartIndexListItem = React.memo(
</footer>
</div>
</article>
</>
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChartIndexPage/ChartIndexNotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function ChartIndexNotFound() {
<Row>
<Column sm={4} md={6} lg={6}>
<p className="component-index-not-found__text">
If you have designs or code for a chart that isn't listed here,
If you have designs or code for a chart that isnt listed here,
please
<Link
className="component-index-not-found__link"
Expand Down
10 changes: 5 additions & 5 deletions src/components/ChartIndexPage/ChartIndexSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ function ChartIndexSearch({ value, onChange }) {
}

ChartIndexSearch.propTypes = {
/**
* Control the value of the search using the `value` prop
*/
value: PropTypes.string.isRequired,

/**
* Receive an update for the latest value and use it to update the passed in
* `value`
*/
onChange: PropTypes.func.isRequired,

/**
* Control the value of the search using the `value` prop
*/
value: PropTypes.string.isRequired,
};

export default ChartIndexSearch;
10 changes: 5 additions & 5 deletions src/components/ChartIndexPage/ChartIndexSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ function ChartIndexSort({ initialSortOption, options, onChange }) {
}

ChartIndexSort.propTypes = {
/**
* Provide the available sort options to be selected
*/
options: PropTypes.arrayOf(PropTypes.string),

/**
* Receive an update for the latest value and use it to update the passed in
* `value`
*/
onChange: PropTypes.func.isRequired,

/**
* Provide the available sort options to be selected
*/
options: PropTypes.arrayOf(PropTypes.string),
};

export default ChartIndexSort;
3 changes: 2 additions & 1 deletion src/components/ChartIndexPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ function ChartIndexPage() {
{filterLabels.map(({ title, options, key }) => (
<div key={key} className="component-index-filter__option">
<legend className="component-index-filter__label">{title}</legend>
{options.map((selectedFilter) => (
{options.map((selectedFilter, i) => (
<Checkbox
key={`${selectedFilter}-${i}`}
labelText={selectedFilter}
id={selectedFilter}
checked={selected.includes(selectedFilter)}
Expand Down
1 change: 0 additions & 1 deletion src/components/ComponentDemo/Code/CodeBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import copy from 'copy-to-clipboard';

import React from 'react';
Expand Down
1 change: 0 additions & 1 deletion src/components/ComponentDemo/Code/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import copy from 'copy-to-clipboard';

import React from 'react';
Expand Down
1 change: 0 additions & 1 deletion src/components/ComponentDemo/ComponentDemo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
/* eslint-disable import/no-extraneous-dependencies */
import React, { useState, useContext } from 'react';
import getTheme from 'gatsby-theme-carbon/src/components/Code/getTheme';
import * as CarbonComponents from 'carbon-components-react';
Expand Down
1 change: 0 additions & 1 deletion src/components/ComponentDemo/DemoContext.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useLayoutEffect } from 'react';

/* eslint-disable import/no-extraneous-dependencies */
import useMedia from 'use-media';
import { breakpoints } from '@carbon/elements';

Expand Down
3 changes: 1 addition & 2 deletions src/components/ComponentDemo/KnobContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-console */
import React, { useContext, useRef } from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { Close20 } from '@carbon/icons-react';
import nanoid from 'nanoid';

Expand Down Expand Up @@ -163,7 +162,7 @@ const Knob = ({
const propString = parsedKnobProps.concat(
Object.entries(newKnobs[component]).reduce(
(accumulator, [prop, value]) => {
if (!value || value === `'default'`) return accumulator;
if (!value || value === `'default'`) {return accumulator;}
if (typeof value === 'boolean') {
return `${accumulator} ${prop}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ const ComponentIndexListItem = React.memo(
};

return (
<>
<article className="component-index-item">
<article className="component-index-item">
<div className="component-index-item__image">{img}</div>
<div className="component-index-item__content">
<header className="component-index-item__name">{name}</header>
Expand Down Expand Up @@ -139,7 +138,6 @@ const ComponentIndexListItem = React.memo(
</footer>
</div>
</article>
</>
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ComponentIndexNotFound() {
<Column sm={4} md={6} lg={6}>
<p className="component-index-not-found__text">
This community component index does not include the Carbon core
components and you may find what you're looking for in the
components and you may find what youre looking for in the
<Link
className="component-index-not-found__link"
href={coreComponentsLink}
Expand Down
9 changes: 4 additions & 5 deletions src/components/ComponentIndexPage/ComponentIndexSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ function ComponentIndexSearch({ value, onChange }) {
}

ComponentIndexSearch.propTypes = {
/**
* Control the value of the search using the `value` prop
*/
value: PropTypes.string.isRequired,

/**
* Receive an update for the latest value and use it to update the passed in
* `value`
*/
onChange: PropTypes.func.isRequired,
/**
* Control the value of the search using the `value` prop
*/
value: PropTypes.string.isRequired,
};

export default ComponentIndexSearch;
10 changes: 5 additions & 5 deletions src/components/ComponentIndexPage/ComponentIndexSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ function ComponentIndexSort({ initialSortOption, options, onChange }) {
}

ComponentIndexSort.propTypes = {
/**
* Provide the available sort options to be selected
*/
options: PropTypes.arrayOf(PropTypes.string),

/**
* Receive an update for the latest value and use it to update the passed in
* `value`
*/
onChange: PropTypes.func.isRequired,

/**
* Provide the available sort options to be selected
*/
options: PropTypes.arrayOf(PropTypes.string),
};

export default ComponentIndexSort;
14 changes: 8 additions & 6 deletions src/components/ComponentIndexPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ function ComponentIndexPage() {
const [selected, setSelected] = useState([]);
const [searchValue, setSearchValue] = useState('');
const [debouncedSearchValue] = useDebounce(searchValue, 300);
const searchClient = useMemo(() => new Fuse(components, searchOptions), [
components,
]);
const searchClient = useMemo(
() => new Fuse(components, searchOptions),
[components]
);

const handleOnChange = (_checkedOption, selectedFilter) => {
// Remove unchecked filter option(s) from setSelected state.
Expand Down Expand Up @@ -158,11 +159,12 @@ function ComponentIndexPage() {
<Column sm={0} md={2} lg={3} className="component-index-filter-container">
<header className="component-index-filter__header">Filters</header>
{filterLabels.map(({ title, options, key }) => (
<fieldset className="component-index-filter__fieldset">
<fieldset key={key} className="component-index-filter__fieldset">
<legend className="component-index-filter__label">{title}</legend>
<div key={key} className="component-index-filter__option">
{options.map((selectedFilter) => (
<div className="component-index-filter__option">
{options.map((selectedFilter, i) => (
<Checkbox
key={`${selectedFilter}-${i}`}
labelText={selectedFilter}
id={selectedFilter}
checked={selected.includes(selectedFilter)}
Expand Down
1 change: 0 additions & 1 deletion src/components/ComponentOverview/ComponentOverview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-dynamic-require */
/* eslint-disable global-require */
import React from 'react';
import { Link } from 'gatsby';
Expand Down
25 changes: 10 additions & 15 deletions src/components/OverviewCard/OverviewCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,26 @@ export default class OverviewCard extends React.Component {

OverviewCard.propTypes = {
children: PropTypes.node,

/**
* Add tag
* Specify a custom class
*/
tag: PropTypes.string,

className: PropTypes.string,
/**
* Set url for card
* Use for disabled card
*/
href: PropTypes.string,

disabled: PropTypes.bool,
/**
* LTitle
* Set url for card
*/
title: PropTypes.string,

href: PropTypes.string,
/**
* Use for disabled card
* Add tag
*/
disabled: PropTypes.bool,

tag: PropTypes.string,
/**
* Specify a custom class
* LTitle
*/
className: PropTypes.string,
title: PropTypes.string,
};

OverviewCard.defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

const { prefix } = settings;

const Profile = ({ name, title, children, ...rest }) => (
const Profile = ({ name, title, children }) => (
<div
className={`${profileContainer} bx--col-md-4 bx--col-lg-4 bx--no-gutter-sm`}>
<div className={`${prefix}--aspect-ratio ${prefix}--aspect-ratio--2x1`}>
Expand All @@ -30,9 +30,9 @@ const Profile = ({ name, title, children, ...rest }) => (
);

Profile.propTypes = {
children: PropTypes.node,
name: PropTypes.string,
title: PropTypes.string,
children: PropTypes.node,
};

export default Profile;
2 changes: 1 addition & 1 deletion src/components/SVGLibraries/IconLibrary/IconLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const IconLibrary = () => {

useEffect(() => {
const iconArray = iconMetaData.reduce((accumulator, icon) => {
if (icon.deprecated) return accumulator;
if (icon.deprecated) {return accumulator;}

const path = [...icon.namespace, icon.name].join('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IconLibrary = () => {
useEffect(() => {
const pictogramArray = pictogramMetaData.reduce(
(accumulator, pictogram) => {
if (pictogram.deprecated) return accumulator;
if (pictogram.deprecated) {return accumulator;}

const path = [...pictogram.namespace, pictogram.name].join('/');

Expand Down
1 change: 0 additions & 1 deletion src/components/SVGLibraries/shared/ActionBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import React, { useRef, useContext, useState } from 'react';
import { pascalCase } from 'change-case';
import { Code16, Download16 } from '@carbon/icons-react';
Expand Down
1 change: 0 additions & 1 deletion src/components/SVGLibraries/shared/LibraryProvider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';

export const LibraryContext = React.createContext();
Expand Down
Loading