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

[NO JIRA]: Upgrade eslint-config-skyscanner to latest to support incomming TS support #2376

Merged
merged 1 commit into from
Feb 17, 2022
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
17 changes: 16 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parser": "babel-eslint",
"extends": [
"skyscanner",
"@skyscanner/eslint-config-skyscanner",
"plugin:flowtype/recommended"
],
"plugins": [
Expand All @@ -28,6 +28,21 @@
"prettier/prettier": "error",
"react/jsx-filename-extension": "off",
"import/no-extraneous-dependencies": "off",
// We override the eslint-config-skyscanner rule here as within Backpack
// we need certain order imports otherwise it will break components like the calendar.
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}
],
// This is superceded by jsx-a11y/label-has-associated-control
"jsx-a11y/label-has-for": "off",
// We want to keep prop-types alongside flow types so we relax this rule to allow us to specify defaults for
Expand Down
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
.*/node_modules/jsonlint/.*
.*/node_modules/config-chain/test/broken.json

# This is expected as this malformed file is for a test in the library.
.*/node_modules/resolve/test/resolver/malformed_package_json/package.json
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add this ignore here to the flowconfig as flow was throuwing an error on an external dependency which is expected as the file is part of a test.


# These libraries show 'malformed' errors in the logs when starting
# the Flow server, so we ignore them.
.*/node_modules/map-or-similar/.*
Expand Down
2 changes: 1 addition & 1 deletion .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const EnhancedThemeProvider = updateOnThemeChange(BpkThemeProvider);

addDecorator(withA11y);
addDecorator(withKnobs);
addDecorator(story => (
addDecorator((story) => (
<div style={{ padding: TOKENS.spacingBase }}>
<EnhancedThemeProvider themeAttributes={themeableAttributes}>
{story()}
Expand Down
2 changes: 1 addition & 1 deletion .storybook/storyshots-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { imageSnapshot } from '@storybook/addon-storyshots-puppeteer';
// See: https://www.npmjs.com/package/@storybook/addon-storyshots-puppeteer#specifying-options-to-jest-image-snapshots
// Its primary function is to delay the screenshot being taken to prevent regressions due to mounting animations & images loading.
const beforeScreenshot = () =>
new Promise(resolve =>
new Promise((resolve) =>
setTimeout(() => {
resolve();
}, 800),
Expand Down
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"resolveNestedSelectors": true
}
],
"unit-blacklist": [["px"], {
"unit-disallowed-list": [["px"], {
"ignoreProperties": {
"px": ["box-shadow"]
}
Expand Down
22 changes: 11 additions & 11 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { includes } from 'lodash';
import { danger, fail, warn, markdown } from 'danger';

// Applies to js, css, scss and sh files that are not located in dist or flow-typed folders.
const shouldContainLicensingInformation = filePath =>
const shouldContainLicensingInformation = (filePath) =>
filePath.match(/\.(js|css|scss|sh)$/) &&
!filePath.includes('dist/') &&
!filePath.includes('flow-typed/');
Expand All @@ -40,9 +40,9 @@ const AVOID_EXACT_WORDS = [
const createdFiles = danger.git.created_files;
const modifiedFiles = danger.git.modified_files;
const fileChanges = [...modifiedFiles, ...createdFiles];
const markdownChanges = fileChanges.filter(path => path.endsWith('md'));
const markdownChanges = fileChanges.filter((path) => path.endsWith('md'));

const svgsChangedOrCreated = fileChanges.some(filePath =>
const svgsChangedOrCreated = fileChanges.some((filePath) =>
filePath.endsWith('svg'),
);

Expand All @@ -54,7 +54,7 @@ if (svgsChangedOrCreated) {
`);
}

const componentChangedOrCreated = fileChanges.some(filePath =>
const componentChangedOrCreated = fileChanges.some((filePath) =>
filePath.match(/packages\/bpk-component.+\/src\/.+\.js/),
);

Expand All @@ -70,7 +70,7 @@ if (componentChangedOrCreated) {
// If any of the packages have changed, the UNRELEASED log should have been updated.
const unreleasedModified = includes(modifiedFiles, 'UNRELEASED.md');
const packagesModified = fileChanges.some(
filePath => filePath.startsWith('packages/') && !filePath.endsWith('.md'),
(filePath) => filePath.startsWith('packages/') && !filePath.endsWith('.md'),
);
if (packagesModified && !unreleasedModified) {
warn(
Expand All @@ -80,13 +80,13 @@ if (packagesModified && !unreleasedModified) {

// If source files have changed, the snapshots should have been updated.
const componentSourceFilesModified = fileChanges.some(
filePath =>
(filePath) =>
// packages/(one or more chars)/src/(one or more chars).js
filePath.match(/packages\/.*bpk-component.+\/src\/.+\.js/) &&
!filePath.includes('-test.'),
);

const snapshotsModified = fileChanges.some(filePath =>
const snapshotsModified = fileChanges.some((filePath) =>
filePath.endsWith('.js.snap'),
);

Expand All @@ -97,7 +97,7 @@ if (componentSourceFilesModified && !snapshotsModified) {
}

// New files should include the Backpack license heading.
const unlicensedFiles = createdFiles.filter(filePath => {
const unlicensedFiles = createdFiles.filter((filePath) => {
if (shouldContainLicensingInformation(filePath)) {
const fileContent = fs.readFileSync(filePath);
return !fileContent.includes(
Expand All @@ -115,7 +115,7 @@ if (unlicensedFiles.length > 0) {
}

const nonModuleCssFiles = fileChanges.filter(
filePath =>
(filePath) =>
filePath.match(/bpk-component/) &&
filePath.match(/\.s?css/) &&
!filePath.match('_') &&
Expand All @@ -129,14 +129,14 @@ if (nonModuleCssFiles.length) {
);
}

markdownChanges.forEach(path => {
markdownChanges.forEach((path) => {
const fileContent = fs.readFileSync(path);

fileContent
.toString()
.split(/\r?\n/)
.forEach((line, lineIndex) => {
AVOID_EXACT_WORDS.forEach(phrase => {
AVOID_EXACT_WORDS.forEach((phrase) => {
if (line.includes(phrase.word)) {
warn(`${phrase.reason} on line ${lineIndex + 1} in ${path}`);
}
Expand Down
Loading