Skip to content

Commit

Permalink
chore: add linting for icons and migrations package (#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschuerch committed Jun 12, 2024
1 parent 6e37a06 commit 1e166d5
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 164 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
"icons:test": "pnpm --filter design-system-icons test",
"icons:unit": "pnpm --filter design-system-icons test",
"icons:unit:watch": "pnpm --filter design-system-icons test:watch",
"icons:lint": "pnpm --filter design-system-icons lint",
"migrations:build": "pnpm --filter design-system-migrations build",
"migrations:lint": "pnpm --filter design-system-migrations lint",
"nextjs": "pnpm nextjs:start",
"nextjs:start": "pnpm --filter design-system-nextjs-integration dev",
"nextjs:build": "pnpm --filter design-system-nextjs-integration build",
Expand Down
37 changes: 37 additions & 0 deletions packages/icons/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
env: {
browser: true,
node: true,
es2021: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json',
},
plugins: ['@typescript-eslint'],
ignorePatterns: ['.eslintrc.js', 'jest.config.js', 'public', 'svgo.config.ts'],
rules: {
'indent': [
'error',
2,
{
SwitchCase: 1,
},
],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
};
6 changes: 5 additions & 1 deletion packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@
"fetchSVGs": "ts-node src/index.ts",
"test": "jest",
"test:watch": "jest --watch",
"test:updatesnapshots": "jest -u"
"test:updatesnapshots": "jest -u",
"lint": "eslint **/*.{js,ts}"
},
"devDependencies": {
"@tsconfig/node18": "18.2.4",
"@types/jest": "29.5.12",
"@types/mock-fs": "4.13.4",
"@types/node": "20.14.0",
"@types/node-fetch": "2.6.11",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"http-server": "14.1.1",
"https-proxy-agent": "7.0.4",
"jest": "29.7.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/icons/src/models/censhare-result-page.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface CenshareResult {
outputChannel: OutputChannel[];
postInfo: PostInfo;
typeFilter: TypeFilter;
size: DetectedColorClass;
size: MediaSize;
downloadLink: string;
hashCode: string;
domain: Domain;
Expand Down Expand Up @@ -101,8 +101,6 @@ export enum Businessfield {
Kommunikation = 'kommunikation',
}

export interface DetectedColorClass {}

export enum Type {
PicturePictogram = 'picture.pictogram.',
}
Expand Down Expand Up @@ -131,7 +129,7 @@ export interface Variant {
domain: Domain;
name: string;
id: number;
detectedColor: DetectedColorClass;
detectedColor: DetectedColor;
workflowId: string;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/icons/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src", "tests"],
"exclude": ["node_modules"]
}
36 changes: 36 additions & 0 deletions packages/migrations/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
env: {
node: true,
es2021: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json',
},
plugins: ['@typescript-eslint'],
ignorePatterns: ['.eslintrc.js', 'dist'],
rules: {
'indent': [
'error',
2,
{
SwitchCase: 1,
},
],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
};
6 changes: 5 additions & 1 deletion packages/migrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"copy-files": "copyfiles -f LICENSE README.md package.json CONTRIBUTING.md CHANGELOG.md src/migrations.json dist",
"build": "tsc -p tsconfig.json && pnpm copy-files",
"clean": "rimraf dist"
"clean": "rimraf dist",
"lint": "eslint **/*.{js,ts}"
},
"dependencies": {
"@angular-devkit/core": "=15.0.4",
Expand All @@ -29,7 +30,10 @@
},
"devDependencies": {
"@types/node": "20.14.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"copyfiles": "2.4.1",
"eslint": "8.57.0",
"rimraf": "5.0.7"
},
"schematics": "./dist/migrations.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ class ReplaceWithElementUpdate implements DomUpdate {

$element.replaceWith($replacement);
});
}
};
}
4 changes: 2 additions & 2 deletions packages/migrations/src/migrations/bootstrap/badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BadgePillClassUpdate implements DomUpdate {
}

class BadgeBGClassUpdate implements DomUpdate {
cssClassRegex: RegExp = new RegExp(`^badge-(${themeColors.join('|')})$`);
cssClassRegex = new RegExp(`^badge-(${themeColors.join('|')})$`);

selector = themeColors.map(colorname => `.badge-${colorname}`).join(', ');

Expand Down Expand Up @@ -52,7 +52,7 @@ class BadgeBGClassUpdate implements DomUpdate {
}

class BadgeOutlineClassUpdate implements DomUpdate {
cssClassRegex: RegExp = new RegExp(`^badge-outline-(${themeColors.join('|')})$`);
cssClassRegex = new RegExp(`^badge-outline-(${themeColors.join('|')})$`);

selector = themeColors.map(colorname => `.badge-outline-${colorname}`).join(', ');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function (): Rule {
}

class ButtonOutlineClassUpdate implements DomUpdate {
cssClassRegex: RegExp = new RegExp(`^btn-outline-(${themeColors.join('|')})$`);
cssClassRegex = new RegExp(`^btn-outline-(${themeColors.join('|')})$`);

selector = themeColors.map(colorname => `.btn-outline-${colorname}`).join(', ');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FormSelectFloatingLabelWrapperUpdate implements DomUpdate {
}

class FormSelectCustomClassesUpdate implements DomUpdate {
cssClassRegex: RegExp = new RegExp(`^form-control-(${breakpoints.join('|')})$`);
cssClassRegex = new RegExp(`^form-control-(${breakpoints.join('|')})$`);
selector = 'select.form-control';

update($elements: Cheerio<AnyNode>, $: CheerioAPI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function (): Rule {
}

class BackgroundOpacityClassesUpdate implements DomUpdate {
cssClassRegex: RegExp = new RegExp(`^bg-(${themeColors.join('|')})-opacity-(\\d+)$`);
cssClassRegex = new RegExp(`^bg-(${themeColors.join('|')})-opacity-(\\d+)$`);

selector = themeColors.map(colorname => `[class*="bg-${colorname}-opacity-"]`).join(', ');

Expand Down
4 changes: 2 additions & 2 deletions packages/migrations/src/migrations/post/stepper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class StepperContainerUpdate implements DomUpdate {
const simpleAriaLabel = $stepperContainer.attr('aria-label');
if (simpleAriaLabel) {
$stepperContainer.removeAttr('aria-label');
$stepperContainer.prepend(`<h2 class="visually-hidden">${simpleAriaLabel}</h2>`)
$stepperContainer.prepend(`<h2 class="visually-hidden">${simpleAriaLabel}</h2>`);
}

const boundAriaLabel = $stepperContainer.attr('[attr.aria-label]');
if (boundAriaLabel) {
$stepperContainer.removeAttr('[attr.aria-label]');
$stepperContainer.prepend(`<h2 class="visually-hidden">{{ ${boundAriaLabel} }}</h2>`)
$stepperContainer.prepend(`<h2 class="visually-hidden">{{ ${boundAriaLabel} }}</h2>`);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/src/migrations/v7/badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BadgeToChipDismissibleUpdate implements DomUpdate {
class BadgeToTagUpdate implements DomUpdate {
selector = '.badge';

bgClassRegex: RegExp = new RegExp(`^bg-(${themeColors.join('|')})$`);
bgClassRegex = new RegExp(`^bg-(${themeColors.join('|')})$`);

update($elements: Cheerio<AnyNode>, $: CheerioAPI) {
$elements.each((_i, element) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/src/utils/dom-migration/dom-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Cheerio, CheerioAPI } from 'cheerio';

export interface DomUpdate {
selector: string;
update: ($elements: Cheerio<any>, $: CheerioAPI) => void;
update: ($elements: Cheerio<unknown>, $: CheerioAPI) => void;
}
Loading

0 comments on commit 1e166d5

Please sign in to comment.