Skip to content

Commit

Permalink
Fixed build packages
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredsgenkins committed Sep 30, 2022
1 parent 89b07e9 commit a81f0b0
Show file tree
Hide file tree
Showing 164 changed files with 1,522 additions and 1,447 deletions.
7 changes: 4 additions & 3 deletions build-packages/create-scandipwa-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const googleAnalytics = require('@scandipwa/scandipwa-dev-utils/analytics');
const templateMap = {
theme: require('@scandipwa/csa-generator-theme'),
blank: require('@scandipwa/csa-generator-blank'),
cra: require('@scandipwa/csa-generator-cra')
cra: require('@scandipwa/csa-generator-cra'),
};

const createApp = async (options) => {
Expand All @@ -24,6 +24,7 @@ const createApp = async (options) => {
if (generator) {
// Run generator if it is available
generator(options);

return;
}

Expand Down Expand Up @@ -99,7 +100,7 @@ yargs.command(
describe: 'Template to create ScandiPWA app from.',
type: 'string',
default: 'theme',
nargs: 1
nargs: 1,
}
);
},
Expand Down Expand Up @@ -129,7 +130,7 @@ yargs.command(
* it should return '@scandipwa/test' as name as 'projects/test' as path.
*/
name: packageName,
path: pathToDist
path: pathToDist,
};

await init(options);
Expand Down
7 changes: 4 additions & 3 deletions build-packages/csa-generator-blank/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const getPackagePath = require('@scandipwa/scandipwa-dev-utils/package-path');
const eslintFix = (destination) => {
const eslintPath = getPackagePath('eslint', destination);
const binPath = path.join(eslintPath, 'bin', 'eslint.js');

return execCommandAsync('node', [
binPath,
'src',
'--resolve-plugins-relative-to', '.',
'--no-error-on-unmatched-pattern',
'--ext', '.js',
'--fix'
'--fix',
], destination);
};

Expand Down Expand Up @@ -92,7 +93,7 @@ const fileSystemCreator = (templateOptions) => (
const run = async (options) => {
const {
name,
path: pathname
path: pathname,
} = options;

const destination = path.join(process.cwd(), pathname);
Expand Down Expand Up @@ -131,7 +132,7 @@ const run = async (options) => {
scandipwaScriptsVersion,
mosaicVersion,
name,
eslintConfigVersion
eslintConfigVersion,
};

// create filesystem from template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable react/forbid-elements */
/* eslint-disable react/forbid-dom-props */
import { PureComponent } from 'react';

import logo from './logo.svg';

import './WelcomePage.style.scss';

/** @namespace Placeholder/Component/WelcomePage/Component/WelcomePageComponent */
/** @namespace Placeholder/Component/WelcomePage/Component */
export class WelcomePageComponent extends PureComponent {
typeMap = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const addWelcomePageRoute = (member) => [
{
position: 1000,
path: '/',
render: (props) => createElement(WelcomePage, props)
}
render: (props) => createElement(WelcomePage, props),
},
];

export default {
'Router/Component/Router/Component/RouterComponent': {
'member-property': {
switchRoutesList: addWelcomePageRoute
}
}
switchRoutesList: addWelcomePageRoute,
},
},
};
7 changes: 4 additions & 3 deletions build-packages/csa-generator-cra/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const getPackagePath = require('@scandipwa/scandipwa-dev-utils/package-path');
const eslintFix = (destination) => {
const eslintPath = getPackagePath('eslint', destination);
const binPath = path.join(eslintPath, 'bin', 'eslint.js');

return execCommandAsync('node', [
binPath,
'src',
'--resolve-plugins-relative-to', '.',
'--no-error-on-unmatched-pattern',
'--ext', '.js',
'--fix'
'--fix',
], destination);
};

Expand Down Expand Up @@ -94,7 +95,7 @@ const fileSystemCreator = (templateOptions) => (
const run = async (options) => {
const {
name,
path: pathname
path: pathname,
} = options;

const destination = path.join(process.cwd(), pathname);
Expand Down Expand Up @@ -156,7 +157,7 @@ const run = async (options) => {
scandipwaScriptsVersion,
mosaicVersion,
eslintConfigVersion,
name
name,
};

// create filesystem from template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable react/forbid-elements */
/* eslint-disable react/forbid-dom-props */
import { PureComponent } from 'react';

import logo from './logo.svg';

import './App.style.scss';

/** @namespace Placeholder/Component/App/Component/AppComponent */
/** @namespace Placeholder/Component/App/Component */
export class AppComponent extends PureComponent {
renderLogo() {
return (
Expand Down
4 changes: 2 additions & 2 deletions build-packages/csa-generator-extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const fileSystemCreator = (templateOptions) => (
const run = async (options) => {
const {
name,
path: pathname
path: pathname,
} = options;

const templateOptions = {
name
name,
};

// create filesystem from template
Expand Down
4 changes: 2 additions & 2 deletions build-packages/csa-generator-theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const fileSystemCreator = (templateOptions) => (
const run = async (options) => {
const {
name,
path: pathname
path: pathname,
} = options;

const destination = path.join(process.cwd(), pathname);
Expand Down Expand Up @@ -174,7 +174,7 @@ const run = async (options) => {
mosaicCracoVersion,
postcssVersion,
proxy: DEFAULT_PROXY,
eslintConfigVersion
eslintConfigVersion,
};

// create filesystem from template
Expand Down
15 changes: 0 additions & 15 deletions build-packages/eslint-plugin-scandipwa-guidelines/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
/* eslint-disable scandipwa-extensibility/no-non-extensible-components */

/**
* @fileoverview Eslint plugin for ScandiPWA development
* @author Alfreds Genkins
*/

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const path = require('path');
const requireIndex = require('requireindex');

//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------

// import all rules in lib/rules
module.exports.rules = requireIndex(path.join(__dirname, 'rules'));
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@tilework/eslint-plugin-mosaic/lib/rules/always-both-mappings');
module.exports = require('@tilework/eslint-plugin-mosaic/lib/rules/always-both-mappings');
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const extractDeclaration = (declarationOrExport) => {
};

const prohibitedOnLevelOne = [
'Literal'
'Literal',
];

const prohibitedInPostfixes = [
'container',
'component'
'component',
];

module.exports = {
Expand All @@ -35,7 +35,7 @@ module.exports = {
Program(node) {
const filePath = context.getFilename();
const exploded = filePath.split(path.sep);
const [fileName, postfix] = exploded[exploded.length - 1].split('.');
const [, postfix] = exploded[exploded.length - 1].split('.');

/**
* Skip all non "component" and "container" files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
const { getIdentifierOccurrences } = require('../util/ast.js');
const { getExpectedClassNameFromFilename, shouldClassNameBeEnforced, getUnexpectedNameMessage } = require('../util/derived-class-name.js');
const { getFilenameFromPath } = require("../util/path.js");
const { getFilenameFromPath } = require('../util/path.js');

module.exports = {
meta: {
Expand All @@ -16,7 +16,7 @@ module.exports = {
fixable: 'code',
},

create: context => ({
create: (context) => ({
ClassDeclaration(node) {
const filePath = context.getFilename();
const fileName = getFilenameFromPath(filePath);
Expand All @@ -37,9 +37,9 @@ module.exports = {
context.report({
loc,
message: getUnexpectedNameMessage(fileName, expectedClassName, actualClassName),
fix: fixer => fixer.replaceText(node, expectedClassName),
fix: (fixer) => fixer.replaceText(node, expectedClassName),
});
})
});
}
},
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@tilework/eslint-plugin-mosaic/lib/rules/export-level-one');
module.exports = require('@tilework/eslint-plugin-mosaic/lib/rules/export-level-one');
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ const path = require('path');
/* eslint-disable no-magic-numbers */
function checkFileName(exploded) {
const fullFileName = exploded[exploded.length - 1];

// Index.js is always OK
if (fullFileName === 'index.js') {
return true;
}

// Do not check paths containing these directories in them
if (exploded.some(elem => ['style', 'query', 'type', 'util'].includes(elem))) {
if (exploded.some((elem) => ['style', 'query', 'type', 'util'].includes(elem))) {
return true;
}

Expand All @@ -30,7 +31,6 @@ function checkFileName(exploded) {
return false;
}


/**
* Returns name of the directory, if file postfix does not match expected.
*/
Expand Down Expand Up @@ -100,53 +100,56 @@ module.exports = {
docs: {
description: 'File structure must comply to the strict guidelines of ScandiPWA',
category: 'Coding standard',
recommended: false
recommended: false,
},
fixable: 'code'
fixable: 'code',
},

create: context => ({
create: (context) => ({
Program(node) {
const filePath = context.getFilename();

if (filePath.indexOf('pwa/src/app') !== -1 || filePath.indexOf('base-theme/src/app') !== -1) {
const pathKey = filePath.indexOf('pwa/src/app') !== -1 ? 'pwa/src/app' : 'base-theme/src/app';
const relativeToApp = filePath.slice(filePath.indexOf(pathKey) + pathKey.length + 1);
const exploded = relativeToApp.split(path.sep);

if (!([
'component', 'query', 'route', 'store', 'style', 'type', 'util', 'index.js'
'component', 'query', 'route', 'store', 'style', 'type', 'util', 'index.js',
].includes(exploded[0]))) {
context.report({
node,
message: 'Extending app directory with custom directories is prohibited.'
message: 'Extending app directory with custom directories is prohibited.',
});
}

if (!checkFileName(exploded)) {
context.report({
node,
message: 'File name should match directory name + postfix (if postfix is needed)'
message: 'File name should match directory name + postfix (if postfix is needed)',
});
}

if (!checkDepth(exploded)) {
context.report({
node,
message: 'Nesting directories is against the principle of flat file structure and is prohobited'
message: 'Nesting directories is against the principle of flat file structure and is prohobited',
});
}

const fileName = exploded[exploded.length - 1];

if (fileName !== 'index.js') {
const directoryThatDoesNotFit = checkPostfix(exploded);

if (directoryThatDoesNotFit) {
context.report({
node,
message: `Postfix of this file does not comply with the ScandiPWA naming convention for the '${directoryThatDoesNotFit}' directory`
message: `Postfix of this file does not comply with the ScandiPWA naming convention for the '${directoryThatDoesNotFit}' directory`,
});
}
}
}
}
})
},
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
docs: {
description: 'Forbid usage of empty PropTypes.shape.',
category: 'Coding standard',
recommended: true
}
recommended: true,
},
},
create: (context) => ({
MemberExpression(node) {
Expand All @@ -19,18 +19,18 @@ module.exports = {
if (node.parent.arguments === undefined) {
context.report({
node: node.property,
message: `Empty PropTypes.shape is forbidden`
message: 'Empty PropTypes.shape is forbidden',
});
}

// PropTypes.shape with empty object as parameter is forbidden (i.e. `PropTypes.shape({})`)
if (node.parent.arguments?.length === 1 && node.parent.arguments[0].properties?.length === 0) {
context.report({
node: node.property,
message: `PropTypes.shape with empty object as parameter is forbidden`
message: 'PropTypes.shape with empty object as parameter is forbidden',
});
}
}
}
})
},
}),
};
Loading

0 comments on commit a81f0b0

Please sign in to comment.