Skip to content

Commit

Permalink
fix: FIx type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Raisa Primerova committed Sep 25, 2024
1 parent a09aa74 commit 83126a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
13 changes: 4 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
"@typescript-eslint/no-explicit-any": "off"
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
},
};
19 changes: 11 additions & 8 deletions scripts/utils/generateRefs.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import fs from 'fs';
import {decodeJSONBufferString} from './parse-utils';
const path = require('path');
import path from 'path';

const transformToRefs = (tokens: any, parsed = {}, level = '') => {
type Transform = (
tokens: Record<string, any>,
parsed?: any,
level?: string
) => Record<string, string[]>;

const transformToRefs: Transform = (tokens, parsed = {}, level = '') => {
const keys = Object.keys(tokens);

keys.forEach(key => {
const isHighestLevel = /base|brand|sys/.test(key);
if (isHighestLevel) {
// @ts-ignore
parsed[key] = [];
}

if (keys.includes('value')) {
// @ts-ignore
parsed.push(level);
parsed?.push(level);
return parsed;
}

transformToRefs(
tokens[key],
// @ts-ignore
isHighestLevel ? parsed[key] : parsed,
isHighestLevel ? '' : level ? `${level}.${key}` : key
);
Expand All @@ -36,11 +39,11 @@ export const generateRefs = async (file: any) => {
const tokens = transformToRefs(file);

if (err || !data) {
fs.writeFile(refsFileName, JSON.stringify(tokens), () => {});
fs.writeFileSync(refsFileName, JSON.stringify(tokens));
} else {
// @ts-ignore

Check failure on line 44 in scripts/utils/generateRefs.ts

View workflow job for this annotation

GitHub Actions / check

Do not use "@ts-ignore" because it alters compilation errors
const content = decodeJSONBufferString(data);
fs.writeFile(refsFileName, JSON.stringify({...content, ...tokens}), () => {});
fs.writeFileSync(refsFileName, JSON.stringify({...content, ...tokens}));
}
});
};

0 comments on commit 83126a5

Please sign in to comment.