diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000000..988c43c4419
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000000..94f480de94e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto eol=lf
\ No newline at end of file
diff --git a/package.json b/package.json
index f55546b4023..234d8dbfc68 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,7 @@
"mutation-observer": "^1.0.3",
"node-sass": "^4.8.3",
"plop": "^2.0.0",
- "prettier": "^1.14.2",
+ "prettier": "^1.16.1",
"prettier-eslint": "^8.8.1",
"prop-types": "^15.6.1",
"react": "^16.3.0",
diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js
index b60d59eae03..d47f4536712 100644
--- a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js
+++ b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js
@@ -93,19 +93,18 @@ class CatalogTileViewCategory extends React.Component {
{title}
- {!viewAll &&
- numShown < totalItems && (
-
-
-
- )}
+ {!viewAll && numShown < totalItems && (
+
+
+
+ )}
{catalogTiles}
diff --git a/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js b/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js
index 37a0215c3b1..e33e8215394 100644
--- a/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js
+++ b/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js
@@ -277,28 +277,27 @@ export class MockFilterExample extends React.Component {
{this.renderInput()}
- {activeFilters &&
- activeFilters.length > 0 && (
-
- Active Filters:
-
- {activeFilters.map((item, index) => (
-
- {item.label}
-
- ))}
-
- {
- e.preventDefault();
- this.clearFilters();
- }}
- >
- Clear All Filters
-
-
- )}
+ {activeFilters && activeFilters.length > 0 && (
+
+ Active Filters:
+
+ {activeFilters.map((item, index) => (
+
+ {item.label}
+
+ ))}
+
+ {
+ e.preventDefault();
+ this.clearFilters();
+ }}
+ >
+ Clear All Filters
+
+
+ )}
);
}
diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js
index 7fcbed9e832..bbe1af21522 100644
--- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js
+++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js
@@ -60,13 +60,12 @@ class LoginCardSocialColumns extends React.Component {
return null;
}
const { expend, width } = this.state;
- const expendButton = width > 768 &&
- links.length > numberOfButtonsToShow && (
-
- );
+ const expendButton = width > 768 && links.length > numberOfButtonsToShow && (
+
+ );
const doubleColumn = links.length > 4 ? 'login-pf-social-double-col' : '';
const moreItems = expend || width < 768 ? this.getHiddenListItems() : null;
diff --git a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js
index f6bd77726c2..ad836bea4ab 100644
--- a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js
+++ b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js
@@ -295,8 +295,8 @@ export class MockClientPaginationTable extends React.Component {
if (checked) {
const updatedSelections = [...new Set([...currentRows.map(r => r.id), ...selectedRows])];
- const updatedRows = rows.map(
- r => (updatedSelections.indexOf(r.id) > -1 ? MockClientPaginationTable.selectRow(r) : r)
+ const updatedRows = rows.map(r =>
+ updatedSelections.indexOf(r.id) > -1 ? MockClientPaginationTable.selectRow(r) : r
);
this.setState({
// important: you must update rows to force a re-render and trigger onRow hook
@@ -307,8 +307,8 @@ export class MockClientPaginationTable extends React.Component {
} else {
const ids = currentRows.map(r => r.id);
const updatedSelections = selectedRows.filter(r => !(ids.indexOf(r) > -1));
- const updatedRows = rows.map(
- r => (updatedSelections.indexOf(r.id) > -1 ? r : MockClientPaginationTable.deselectRow(r))
+ const updatedRows = rows.map(r =>
+ updatedSelections.indexOf(r.id) > -1 ? r : MockClientPaginationTable.deselectRow(r)
);
this.setState({
rows: updatedRows,
diff --git a/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js b/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js
index de22f88636c..8fb4f02a42f 100644
--- a/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js
+++ b/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js
@@ -318,30 +318,29 @@ export class MockToolbarExample extends React.Component {
40 Results
))}
- {activeFilters &&
- activeFilters.length > 0 && (
-
- 40 Results
- Active Filters:
-
- {activeFilters.map((item, index) => (
-
- label=
- {item.label}
-
- ))}
-
- {
- e.preventDefault();
- this.clearFilters();
- }}
- >
- Clear All Filters
-
-
- )}
+ {activeFilters && activeFilters.length > 0 && (
+
+ 40 Results
+ Active Filters:
+
+ {activeFilters.map((item, index) => (
+
+ label=
+ {item.label}
+
+ ))}
+
+ {
+ e.preventDefault();
+ this.clearFilters();
+ }}
+ >
+ Clear All Filters
+
+
+ )}
);
}
diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js
index 180c7a03b91..394a304cb12 100644
--- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js
+++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js
@@ -282,25 +282,24 @@ class BaseVerticalNavItemHelper extends React.Component {
{title}
{showBadges && childBadgeComponents && {childBadgeComponents}
}
- {childItemComponents &&
- childItemComponents.length > 0 && (
-
-
- {(pinnableMenus || isMobile) && (
-
- )}
-
{title}
-
-
- {childItemComponents}
-
+ {childItemComponents && childItemComponents.length > 0 && (
+
+
+ {(pinnableMenus || isMobile) && (
+
+ )}
+
{title}
- )}
+
+ {childItemComponents}
+
+
+ )}
);
diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js
index b2005704448..cde44b59d2f 100644
--- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js
+++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js
@@ -60,20 +60,18 @@ export class WizardExample extends MockWizardBase {
)}
- {activeStepIndex === 2 &&
- activeSubStepIndex === 0 && (
-
- )}
- {activeStepIndex === 2 &&
- activeSubStepIndex === 1 && (
-
- )}
+ {activeStepIndex === 2 && activeSubStepIndex === 0 && (
+
+ )}
+ {activeStepIndex === 2 && activeSubStepIndex === 1 && (
+
+ )}
diff --git a/packages/patternfly-3/react-console/src/AccessConsoles/AccessConsoles.js b/packages/patternfly-3/react-console/src/AccessConsoles/AccessConsoles.js
index c0169a045a9..3775838f958 100644
--- a/packages/patternfly-3/react-console/src/AccessConsoles/AccessConsoles.js
+++ b/packages/patternfly-3/react-console/src/AccessConsoles/AccessConsoles.js
@@ -59,14 +59,12 @@ class AccessConsoles extends React.Component {
getConsoleForType(type) {
// To keep connection, render all consoles but hide those unused
- return React.Children.map(
- this.props.children,
- child =>
- this.state.keptConnection[getChildTypeName(child)] ? (
-
- {child}
-
- ) : null
+ return React.Children.map(this.props.children, child =>
+ this.state.keptConnection[getChildTypeName(child)] ? (
+
+ {child}
+
+ ) : null
);
}
@@ -105,17 +103,16 @@ class AccessConsoles extends React.Component {
)}
- {this.state.type !== NONE_TYPE &&
- this.state.type !== DESKTOP_VIEWER_CONSOLE_TYPE && (
- this.onChangeDisconnectBySwitchClick(e.target)}
- >
- {this.props.textDisconnectByChange}
-
- )}
+ {this.state.type !== NONE_TYPE && this.state.type !== DESKTOP_VIEWER_CONSOLE_TYPE && (
+ this.onChangeDisconnectBySwitchClick(e.target)}
+ >
+ {this.props.textDisconnectByChange}
+
+ )}
diff --git a/packages/patternfly-4/react-styles/src/build/util.js b/packages/patternfly-4/react-styles/src/build/util.js
index 92c4dbbef36..5ecd47c03e3 100644
--- a/packages/patternfly-4/react-styles/src/build/util.js
+++ b/packages/patternfly-4/react-styles/src/build/util.js
@@ -40,7 +40,7 @@ export function writeCSSJSFile(rootPath, originalPath, destinationPath, contents
export function getRelativeImportPath(from, to) {
const parsedTo = path.parse(to);
- const newImportPath = path.normalize(path.join(relative(from, parsedTo.dir), parsedTo.base).replace(/\\/g, ''));
+ const newImportPath = path.normalize(path.join(relative(from, parsedTo.dir), parsedTo.base));
return newImportPath.startsWith('.') ? newImportPath : `./${newImportPath}`;
}
diff --git a/packages/patternfly-4/react-tokens/build/generateTokens.test.js b/packages/patternfly-4/react-tokens/build/generateTokens.test.js
index ea9413b6d15..69026948bb9 100644
--- a/packages/patternfly-4/react-tokens/build/generateTokens.test.js
+++ b/packages/patternfly-4/react-tokens/build/generateTokens.test.js
@@ -55,7 +55,7 @@ test('keeps variable reference if computing fails', () => {
function getOutputs() {
return outputFileSyncMock.mock.calls.reduce((acc, call) => {
const [filePath, content] = call;
- const splitPath = filePath.split('/');
+ const splitPath = filePath.split(/[/\\]/);
const name = splitPath.slice(-2).join('/');
return {
...acc,
diff --git a/packages/react-codemods/transforms/pf3-pf4.button.test.js b/packages/react-codemods/transforms/pf3-pf4.button.test.js
index fb48dc3ef48..8b85ef15409 100644
--- a/packages/react-codemods/transforms/pf3-pf4.button.test.js
+++ b/packages/react-codemods/transforms/pf3-pf4.button.test.js
@@ -1,9 +1,29 @@
+import { EOL as SYSTEM_EOL } from 'os';
import prettier from 'prettier';
import { defineInlineTest } from 'jscodeshift/dist/testUtils';
import transform from './pf3-pf4';
-const prettierConfig = prettier.resolveConfig.sync(process.cwd());
-const pretty = src => prettier.format(src, { parser: 'babylon', ...prettierConfig });
+/**
+ * Codemod outputs should follow the EOL pattern of the target codebase, not
+ * Patternfly's. Patternfly currently enforces LF as line ending, independent of
+ * the OS building the codebase.
+ *
+ * JSCodeShift produces OS-dependent line endings however, LF for Unix based
+ * systems, and CRLF for Windows based ones. This is also likely what most
+ * projects would like to see the codemod prduce.
+ *
+ * To make sure we both adhere to Patternfly's conventions, and compare the
+ * correct OS-specific line endings during the test cases' assertions, we store
+ * expected values with LF line endings, and convert them into the OS-specific
+ * ones at runtime using prettier.
+ */
+const PRETTIER_EOL = SYSTEM_EOL === '\r\n' ? 'crlf' : 'cr';
+const prettierConfig = {
+ ...prettier.resolveConfig.sync(process.cwd()),
+ parser: 'babel',
+ endOfLine: PRETTIER_EOL
+};
+const pretty = src => prettier.format(src, prettierConfig);
global.console.log = jest.fn();
diff --git a/packages/react-codemods/transforms/pf3-pf4.js b/packages/react-codemods/transforms/pf3-pf4.js
index ce02db52dce..22c5b820cee 100644
--- a/packages/react-codemods/transforms/pf3-pf4.js
+++ b/packages/react-codemods/transforms/pf3-pf4.js
@@ -149,7 +149,7 @@ module.exports = (file, api, options) => {
return prettier
? prettier.format(transformedSource, {
- parser: 'babylon',
+ parser: 'babel',
...prettier.resolveConfig.sync(process.cwd())
})
: transformedSource;
diff --git a/packages/react-codemods/transforms/pf3-pf4.test.js b/packages/react-codemods/transforms/pf3-pf4.test.js
index bf792d9247f..209e9c40af6 100644
--- a/packages/react-codemods/transforms/pf3-pf4.test.js
+++ b/packages/react-codemods/transforms/pf3-pf4.test.js
@@ -1,9 +1,29 @@
+import { EOL as SYSTEM_EOL } from 'os';
import prettier from 'prettier';
import { defineInlineTest, runInlineTest } from 'jscodeshift/dist/testUtils';
import transform from './pf3-pf4';
-const prettierConfig = prettier.resolveConfig.sync(process.cwd());
-const pretty = src => prettier.format(src, { parser: 'babylon', ...prettierConfig });
+/**
+ * Codemod outputs should follow the EOL pattern of the target codebase, not
+ * Patternfly's. Patternfly currently enforces LF as line ending, independent of
+ * the OS building the codebase.
+ *
+ * JSCodeShift produces OS-dependent line endings however, LF for Unix based
+ * systems, and CRLF for Windows based ones. This is also likely what most
+ * projects would like to see the codemod prduce.
+ *
+ * To make sure we both adhere to Patternfly's conventions, and compare the
+ * correct OS-specific line endings during the test cases' assertions, we store
+ * expected values with LF line endings, and convert them into the OS-specific
+ * ones at runtime using prettier.
+ */
+const PRETTIER_EOL = SYSTEM_EOL === '\r\n' ? 'crlf' : 'cr';
+const prettierConfig = {
+ ...prettier.resolveConfig.sync(process.cwd()),
+ parser: 'babel',
+ endOfLine: PRETTIER_EOL
+};
+const pretty = src => prettier.format(src, prettierConfig);
global.console.log = jest.fn();
diff --git a/yarn.lock b/yarn.lock
index 2d03a700463..8f1a9310329 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -16699,7 +16699,7 @@ prettier@^1.14.2:
version "1.14.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.2.tgz#0ac1c6e1a90baa22a62925f41963c841983282f9"
-prettier@^1.16.0:
+prettier@^1.16.0, prettier@^1.16.1:
version "1.16.4"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"