Skip to content

Commit

Permalink
fix some lint + remove usage of talend-script when a circular deps is…
Browse files Browse the repository at this point in the history
… identified
  • Loading branch information
smouillour committed Oct 12, 2023
1 parent f8b7bde commit ad68589
Show file tree
Hide file tree
Showing 54 changed files with 192 additions and 174 deletions.
31 changes: 10 additions & 21 deletions fork/dynamic-cdn-webpack-plugin/src/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ function findPackagesFromScopeFolder(scope, name, scopeFolderPath) {
return accu.concat(subFolderPath);
}
// NOT COMPATIBLE WITH PNPM
// // the scope or package name is not the one we look for
// // if there is a nested node modules folder, we dive into it for the search
// const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules');
// if (fs.existsSync(nestedNodeModulesPath)) {
// return accu.concat(
// findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, []),
// );
// }
// the scope or package name is not the one we look for
// if there is a nested node modules folder, we dive into it for the search
const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules');
if (fs.existsSync(nestedNodeModulesPath)) {
// eslint-disable-next-line no-use-before-define
return accu.concat(findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, []));
}
return accu;
}, []);
}
Expand All @@ -59,25 +58,15 @@ function findPackagesFromNonScopeFolder(scope, name, nonScopeFolderPath) {
// for scope folders, we need a special treatment to avoid getting scoped packages when we don't want a scoped one.
// ex: search for `classnames`, we don't want to find `@types/classnames` in the result
return accu.concat(
findPackagesFromScopeFolder(
scope,
name,
path.join(nonScopeFolderPath, subFolder.name),
),
findPackagesFromScopeFolder(scope, name, path.join(nonScopeFolderPath, subFolder.name)),
);
} else if (!scope && subFolder.name === name) {
// we want a NON scoped package, we are in a non scoped folder, and the names match
return accu.concat(path.join(nonScopeFolderPath, subFolder.name));
}
const nestedNodeModulesPath = path.join(
nonScopeFolderPath,
subFolder.name,
'node_modules',
);
const nestedNodeModulesPath = path.join(nonScopeFolderPath, subFolder.name, 'node_modules');
if (fs.existsSync(nestedNodeModulesPath)) {
return accu.concat(
findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath),
);
return accu.concat(findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath));
}
return accu;
}, []);
Expand Down
4 changes: 1 addition & 3 deletions fork/module-to-cdn/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
}
{}
3 changes: 1 addition & 2 deletions fork/module-to-cdn/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"root": true,
"extends": "@talend"
"root": true
}
2 changes: 1 addition & 1 deletion fork/module-to-cdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"scripts": {
"test": "jest index.test.js",
"test:cron": "jest modules.test.js",
"lint": "talend-scripts lint ./"
"lint": "echo \"Not possible to use talend-scripts here (risk of circular dependency)\" && exit 0"
},
"files": [
"index.js",
Expand Down
1 change: 0 additions & 1 deletion packages/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-prettier": "^12.0.0",
"@talend/scripts-config-typescript": "^11.1.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/assets-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
},
"dependencies": {},
"devDependencies": {
"@talend/babel-plugin-import-from-index": "^1.5.1",
"@talend/icons": "^6.60.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
"@talend/scripts-config-babel": "^13.0.0",
"@talend/scripts-config-react-webpack": "^16.0.0",
"@talend/scripts-config-typescript": "^11.1.0",
"read-pkg-up": "^7.0.1"
},
"publishConfig": {
Expand Down
5 changes: 3 additions & 2 deletions packages/assets-api/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ describe('assets-api', () => {
it('should prevent // as start url', () => {
const original = window.Talend.CDN_URL;
window.Talend.CDN_URL = '/cdn';
const mockedBaseElement = { getAttribute: jest.fn().mockReturnValueOnce('/') };
// @ts-ignore
const mockedBaseElement = {
getAttribute: jest.fn().mockReturnValueOnce('/'),
} as unknown as Element;
jest.spyOn(document, 'querySelector').mockImplementation(() => mockedBaseElement);
const url = assetsApi.getURL(bundlePath, '@talend/icons', iconsInfo?.packageJson.version);
expect(url).toBe(`/cdn/@talend/icons/${iconsInfo?.packageJson.version}${bundlePath}`);
Expand Down
1 change: 0 additions & 1 deletion packages/cmf-cqrs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"redux-saga": "^1.2.3"
},
"devDependencies": {
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
"@talend/scripts-config-typescript": "^11.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/cmf-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"devDependencies": {
"@redux-saga/testing-utils": "^1.1.5",
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
"react": "^17.0.2",
Expand Down
1 change: 0 additions & 1 deletion packages/cmf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
},
"devDependencies": {
"@redux-saga/testing-utils": "^1.1.5",
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-jest": "^12.2.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/cmf/src/reduxstorage/reduxLocalStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import createEngine from 'redux-storage-engine-localstorage';
import filter from 'redux-storage-decorator-filter';
import immutablejs from './redux-storage-decorator-immutablejs';

const CMF_IMMUTABLE_PATHS = [['cmf', 'components'], ['cmf', 'collections']];
const CMF_IMMUTABLE_PATHS = [
['cmf', 'components'],
['cmf', 'collections'],
];

const CMF_MIDDLEWARE_BLACK_LIST = ['@@INIT', '@@router/LOCATION_CHANGE'];

Expand Down
1 change: 0 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"@talend/bootstrap-theme": "^8.2.0",
"@talend/design-system": "^7.15.1",
"@talend/icons": "^6.60.1",
"@talend/eslint-plugin": "^1.0.1",
"@talend/locales-design-system": "^7.3.0",
"@talend/locales-tui-components": "^9.5.0",
"@talend/scripts-config-stylelint": "^4.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/containers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"devDependencies": {
"@storybook/addon-actions": "^7.4.1",
"@talend/bootstrap-theme": "^8.2.0",
"@talend/eslint-plugin": "^1.0.1",
"@talend/icons": "^6.60.1",
"@talend/locales-tui-containers": "^8.0.2",
"@talend/react-storybook-cmf": "^7.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/dataviz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@cypress/webpack-dev-server": "^3.6.1",
"@talend/bootstrap-theme": "^8.2.0",
"@talend/design-system": "^7.15.1",
"@talend/eslint-plugin": "^1.0.1",
"@talend/icons": "^6.60.1",
"@talend/locales-tui-components": "^9.5.0",
"@talend/locales-tui-dataviz": "^0.4.6",
Expand Down
1 change: 0 additions & 1 deletion packages/design-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"@storybook/testing-library": "^0.2.0",
"@storybook/testing-react": "^2.0.1",
"@storybook/theming": "^7.4.1",
"@talend/eslint-plugin": "^1.0.1",
"@talend/locales-design-system": "^7.3.0",
"@talend/locales-tui-components": "^9.5.0",
"@talend/locales-tui-containers": "^8.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@talend/locales-design-system": "^7.3.0",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
"@talend/scripts-config-typescript": "^11.1.0",
"@talend/storybook-docs": "^1.2.0",
"@testing-library/cypress": "^9.0.0",
"@types/classnames": "^2.3.1",
Expand Down
1 change: 0 additions & 1 deletion packages/design-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@talend/scripts-config-typescript": "^11.1.0",
"@talend/babel-plugin-import-from-index": "^1.5.1",
"@talend/babel-plugin-assets-api": "^1.1.0",
"@talend/eslint-plugin": "^1.0.1",
"typeface-source-sans-pro": "^1.1.13"
},
"dependencies": {}
Expand Down
1 change: 0 additions & 1 deletion packages/flow-designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"devDependencies": {
"@talend/babel-plugin-import-from-index": "^1.5.1",
"@talend/babel-plugin-assets-api": "^1.1.0",
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-config-jest": "^12.2.0",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@storybook/addon-actions": "^7.4.1",
"@storybook/addon-controls": "^7.4.1",
"@talend/bootstrap-theme": "^8.2.0",
"@talend/eslint-plugin": "^1.0.1",
"@talend/icons": "^6.60.1",
"@talend/locales-tui-forms": "^9.0.1",
"@talend/react-components": "^11.4.0",
Expand Down
1 change: 0 additions & 1 deletion packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"lint": "talend-scripts lint"
},
"devDependencies": {
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-babel": "^13.0.0",
"@talend/scripts-config-react-webpack": "^16.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/local-libs-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"access": "public"
},
"devDependencies": {
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^15.0.0",
"jest-cli": "^29.7.0"
}
Expand Down
8 changes: 7 additions & 1 deletion packages/storybook-docs/src/components/FigmaContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import * as Figma from 'figma-js';

const token = process.env.STORYBOOK_FIGMA_ACCESS_TOKEN;

export default createContext({
interface FigmaClient extends ReturnType<typeof Figma.Client> {
isConfigured: boolean;
}

export const FigmaContext = createContext<FigmaClient>({
// eslint-disable-next-line new-cap
...Figma.Client({
personalAccessToken: token,
}),
isConfigured: !!token,
});

export default FigmaContext;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Trial } from './Trial';

import { Meta, StoryFn } from '@storybook/react';

export default {
const meta: Meta<typeof Trial> = {
component: Trial,
} as Meta<typeof Trial>;
};

export default meta;

export const Story: StoryFn<typeof Trial> = () => {
return <Trial>Trial component</Trial>;
Expand Down
4 changes: 2 additions & 2 deletions packages/storybook-docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
{
"extends": "@talend/scripts-config-typescript/tsconfig.json",
"include": ["src/**/*", "custom.d.ts"],
"files": [],
"compilerOptions": {
"declaration": true,
"declaration": true
}
}
2 changes: 1 addition & 1 deletion tools/babel-plugin-assets-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "src/index.js",
"scripts": {
"lint": "talend-scripts lint",
"lint": "echo \"Not possible to use talend-scripts here (risk of circular dependency)\" && exit 0",
"test": "jest"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions tools/babel-plugin-import-d3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test": "jest"
},
"devDependencies": {
"@talend/scripts-core": "^15.0.0",
"@babel/core": "^7.22.20",
"@babel/preset-env": "^7.22.20",
"babel-jest": "^29.7.0",
Expand Down
26 changes: 5 additions & 21 deletions tools/babel-plugin-import-d3/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ function findD3RelatedPackageName(importDeclarationPath) {
return found;
}

function getLastNameInPath(path) {
const splited = path.split('/');
if (splited.length === 1) {
return false;
}
return splited.pop();
}

function sortImports(a, b) {
if (a.type === 'ImportDefaultSpecifier') {
return -1;
Expand All @@ -62,35 +54,31 @@ module.exports = function transform({ types }) {
const d3Packages = [];
const requireCalls = [];
let lastImport;
let realLastImport;

path.traverse({
CallExpression: {
exit(callExpression) {
if (callExpression.node.callee.name === 'require') {
if (PACKAGES.indexOf(callExpression.node.arguments[0].value) !== -1) {
const mod = callExpression.node.arguments[0].value.replace('d3-', '');
// eslint-disable-next-line no-param-reassign
callExpression.node.arguments[0] = types.stringLiteral('d3');
// we must wrap callexpression into memberexpression
requireCalls.push({
callExpression,
replace: types.memberExpression(
callExpression.node,
types.identifier(mod),
)
replace: types.memberExpression(callExpression.node, types.identifier(mod)),
});
callExpression.remove();
}
}
}
},
},
ImportDeclaration: {
exit(importDeclarationPath) {
realLastImport = importDeclarationPath;
const packageName = findD3RelatedPackageName(importDeclarationPath);
if (packageName) {
d3Packages.push(
...importDeclarationPath.node.specifiers.map(({ local, imported, type }) => {
...importDeclarationPath.node.specifiers.map(({ local, imported }) => {
const localName = local.name;
let importedName = localName;
if (imported) {
Expand All @@ -112,13 +100,9 @@ module.exports = function transform({ types }) {
requireCalls.forEach(info => {
info.callExpression.insertAfter(info.replace);
});
const packageName = 'd3';
if (d3Packages.length > 0) {
const source = types.stringLiteral('d3');
const imp = types.importDeclaration(
d3Packages.filter(Boolean).sort(sortImports),
source,
);
const imp = types.importDeclaration(d3Packages.filter(Boolean).sort(sortImports), source);
if (lastImport) {
lastImport.insertAfter(imp);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/babel-plugin-import-from-index/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "https://github.com/Talend/ui.git"
},
"scripts": {
"lint": "talend-scripts lint",
"lint": "echo \"Not possible to use talend-scripts here (risk of circular dependency)\" && exit 0",
"test": "jest"
},
"dependencies": {
Expand Down
Loading

0 comments on commit ad68589

Please sign in to comment.