Skip to content

Commit

Permalink
[ARGG-799]: Migrates from bpk-tokens to bpk-foundations-web (#85)
Browse files Browse the repository at this point in the history
* [ARGG-799]: Migrates from bpk-tokens to bpk-foundations-web

* Remove console log
  • Loading branch information
olliecurtis authored Oct 26, 2023
1 parent 5d793a6 commit 3c80fef
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 648 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ Available for colours and length values. Will prevent the use of a hardcoded col
"autoImport": true,
"platform": "web",
"tokensPackage": {
"web": "bpk-tokens/tokens/base.es6",
"native": "bpk-tokens/tokens/base.react.native",
"web": "@skyscanner/bpk-foundations-web/tokens/base.es6",
},
}]
}
Expand Down
89 changes: 53 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"bpk-tokens": "^36.0.0",
"@skyscanner/bpk-foundations-web": "^17.3.0",
"lodash": "^4.17.21",
"tinycolor2": "^1.6.0"
},
Expand Down
12 changes: 1 addition & 11 deletions src/rules/use-components/use-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@
const merge = require('lodash/merge');

const useWebComponents = require('./use-web-components');
const useNativeComponents = require('./use-native-components');

const BASE_CONFIG = {
autoImport: true,
platform: 'web',
};

const createConfigForPlatform = (report, options) => {
const config = merge({}, BASE_CONFIG, options[0]);
if (config.platform === 'web') {
return useWebComponents(report, options);
}
return useNativeComponents(report, options);
return useWebComponents(report, options);
};

module.exports = {
Expand Down
111 changes: 0 additions & 111 deletions src/rules/use-components/use-components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const { RuleTester } = require('eslint');

const useComponents = require('./use-components');

const BPK_PATH = 'backpack-react-native/';

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2015,
Expand All @@ -30,115 +28,6 @@ const ruleTester = new RuleTester({
},
});

/* platform: 'native' tests. */
[
['ActivityIndicator', 'BpkSpinner', 'bpk-component-spinner'],
['Alert', 'BpkAlert', 'bpk-component-alert'],
['Button', 'BpkButton', 'bpk-component-button'],
['FlatList', 'BpkFlatList', 'bpk-component-flat-list'],
['Image', 'BpkImage', 'bpk-component-image'],
['Picker', 'BpkPicker', 'bpk-component-picker'],
['SectionList', 'BpkSectionList', 'bpk-component-section-list'],
['Switch', 'BpkSwitch', 'bpk-component-switch'],
['Text', 'BpkText', 'bpk-component-text'],
['TextInput', 'BpkTextInput', 'bpk-component-text-input'],
[
'TouchableHighlight',
'BpkTouchableOverlay',
'bpk-component-touchable-overlay',
],
[
'TouchableNativeFeedback',
'BpkTouchableNativeFeedback',
'bpk-component-touchable-native-feedback',
],
].forEach(([Component, Substitute, pkg]) => {
const pkgPath = BPK_PATH + pkg;

ruleTester.run(`use-components (native) - ${Component}`, useComponents, {
valid: [
`<${Substitute}>I'm allowed</${Substitute}>`,
`<div>I'm allowed</div>`,
`React.createElement(SomeElement, null)`,
`React.createElement("div", null)`,
],
invalid: [
{
options: [{ platform: 'native' }],
code: `React.createElement(${Component}, null, "I'm not allowed")`,
output: `
import ${Substitute} from '${pkgPath}';
React.createElement(${Substitute}, null, "I'm not allowed")`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
{
options: [{ platform: 'native' }],
code: `create(${Component}, null, "I'm not allowed")`,
output: `
import ${Substitute} from '${pkgPath}';
create(${Substitute}, null, "I'm not allowed")`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
{
options: [{ platform: 'native' }],
code: `<${Component}>I'm not allowed</${Component}>`,
output: `
import ${Substitute} from '${pkgPath}';
<${Substitute}>I'm not allowed</${Substitute}>`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
{
options: [{ platform: 'native' }],
code: `<${Component} children="I'm not allowed" />`,
output: `
import ${Substitute} from '${pkgPath}';
<${Substitute} children="I'm not allowed" />`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
{
options: [{ autoImport: false, platform: 'native' }],
code: `<${Component} children="I'm not allowed" />`,
output: `<${Substitute} children="I'm not allowed" />`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
{
options: [{ platform: 'native' }],
code: `
import ${Substitute} from '${pkgPath}';
<${Component} children="I'm not allowed" />`,
output: `
import ${Substitute} from '${pkgPath}';
<${Substitute} children="I'm not allowed" />`,
errors: [
{
message: `Use the following Backpack component instead: ${Substitute}`,
},
],
},
],
});
});

/* platform: 'web' tests */
const createImportStatement = (Substitute, useDefaultImport, pkgPath) =>
`import ${
Expand Down
Loading

0 comments on commit 3c80fef

Please sign in to comment.