Skip to content

Commit

Permalink
Merge pull request #3 from SPF-Open/Eslint-fix
Browse files Browse the repository at this point in the history
Eslint fix
  • Loading branch information
Benoit-Welsch authored Nov 23, 2023
2 parents acce98a + 6c8995a commit ea56da3
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 203 deletions.
28 changes: 14 additions & 14 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ module.exports = {
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:svelte/recommended",
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}", "*.svelte"],
files: ['.eslintrc.{js,cjs}', '*.svelte'],
parserOptions: {
sourceType: "script",
parser: "@typescript-eslint/parser",
sourceType: 'script',
parser: '@typescript-eslint/parser',
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ["@typescript-eslint"],
plugins: ['@typescript-eslint'],
rules: {
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
"@typescript-eslint/no-unused-vars": "warn",
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'@typescript-eslint/no-unused-vars': 'warn',
},
};
3 changes: 1 addition & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ jobs:
- name: Run ESLint
run: npx eslint .
--config .eslintrc.cjs
--ext .js,.jsx,.ts,.tsx,.svelte
--config .eslintrc.js
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
continue-on-error: true
Expand Down
98 changes: 49 additions & 49 deletions src/lib/Input/Download.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,65 @@
{ offset: $rowOffset },
);
switch ($selectedFormat.toLocaleLowerCase()) {
case 'csv': {
const CSVString = exportToCSV(sheet, { lang: $langOutput });
case 'csv': {
const CSVString = exportToCSV(sheet, { lang: $langOutput });
const blob = new Blob([CSVString], { type: 'text/csv;charset=utf-8,' });
const objUrl = URL.createObjectURL(blob);
const blob = new Blob([CSVString], { type: 'text/csv;charset=utf-8,' });
const objUrl = URL.createObjectURL(blob);
linkFile.href = objUrl;
console.log(fileName);
linkFile.download = fileName + ' - ' + $langOutput;
linkFile.click();
break;
}
case 'pdf': {
window.print();
break;
}
case 'qti': {
const lang = $langOutput;
const { manifest, questionsManifest } = exportToQTI(sheet, {
lang,
});
linkFile.href = objUrl;
console.log(fileName);
linkFile.download = fileName + ' - ' + $langOutput;
linkFile.click();
break;
}
case 'pdf': {
window.print();
break;
}
case 'qti': {
const lang = $langOutput;
const { manifest, questionsManifest } = exportToQTI(sheet, {
lang,
});
const manifestBlob = new Blob([manifest.toString()], {
type: 'text/xml',
});
const questionsManifestBlob = questionsManifest.map(
(q) => new Blob([q.toString()], { type: 'text/xml' }),
);
const manifestBlob = new Blob([manifest.toString()], {
type: 'text/xml',
});
const questionsManifestBlob = questionsManifest.map(
(q) => new Blob([q.toString()], { type: 'text/xml' }),
);
const ex = async () => {
const zipFileStream = new TransformStream();
const zipFileBlobPromise = new Response(
zipFileStream.readable,
).blob();
const ex = async () => {
const zipFileStream = new TransformStream();
const zipFileBlobPromise = new Response(
zipFileStream.readable,
).blob();
const zipWriter = new ZipWriter(new BlobWriter('application/zip'));
const zipWriter = new ZipWriter(new BlobWriter('application/zip'));
// Create manifest xml file
await zipWriter.add('imsmanifest.xml', new BlobReader(manifestBlob));
// Create manifest xml file
await zipWriter.add('imsmanifest.xml', new BlobReader(manifestBlob));
await Promise.all(
questionsManifestBlob.map((b, n) =>
zipWriter.add(`items/${n}/qti.xml`, new BlobReader(b)),
),
);
await Promise.all(
questionsManifestBlob.map((b, n) =>
zipWriter.add(`items/${n}/qti.xml`, new BlobReader(b)),
),
);
const finalBlob = await zipWriter.close();
const finalBlob = await zipWriter.close();
linkFile.setAttribute('href', URL.createObjectURL(finalBlob));
linkFile.download = fileName + '.zip';
linkFile.click();
};
ex();
linkFile.setAttribute('href', URL.createObjectURL(finalBlob));
linkFile.download = fileName + '.zip';
linkFile.click();
};
ex();
break;
}
default: {
console.log('Not unsuported yet');
}
break;
}
default: {
console.log('Not unsuported yet');
}
}
};
</script>
Expand Down
16 changes: 8 additions & 8 deletions src/lib/helper/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ export class CSV extends Array<Array<string | number>> {
toString(): string {
return this.map((c) =>
c
.map((e) => (typeof e === "string" ? '"' + e.trim() + '"' : e))
.join(";"),
).join("\r\n");
.map((e) => (typeof e === 'string' ? '"' + e.trim() + '"' : e))
.join(';'),
).join('\r\n');
}

toStringEncoded() {
const rules = [
{
from: /(\r\n|\n|\r)/gm,
to: " ",
to: ' ',
},
{
from: '"',
Expand All @@ -42,18 +42,18 @@ export class CSV extends Array<Array<string | number>> {
return this.map((l) =>
l
.map((v) => {
if (typeof v === "string") {
if (typeof v === 'string') {
rules.forEach(({ from, to }) => {
//@ts-expect-error 'v' will always be a string in this case
v = v.replaceAll(from, to);
});
}
return v;
})
.map((e) => (typeof e === "string" ? '"' + e.trim() + '"' : e)) // Add trailing ""
.join(";"),
.map((e) => (typeof e === 'string' ? '"' + e.trim() + '"' : e)) // Add trailing ""
.join(';'),
) // Add CSV separator
.join("\r\n"); // Add break line
.join('\r\n'); // Add break line
}

// static readString(csv: string) {
Expand Down
30 changes: 15 additions & 15 deletions src/lib/helper/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,27 @@ export class QCM extends Question {
getFakeId(lang: string, n: number) {
return (
langZone(lang).titlePrefix +
(n + 1 < 10 ? "0" + (n + 1) : n + 1).toString()
(n + 1 < 10 ? '0' + (n + 1) : n + 1).toString()
);
}
}

export const langZone = (lang: string) => {
let zone = "";
let titlePrefix = "";
let zone = '';
let titlePrefix = '';
switch (lang) {
case "FR":
zone = "fr-FR";
titlePrefix = "QCM ";
break;
case "NL":
zone = "nl-NL";
titlePrefix = "MKV ";
break;
case "DE":
zone = "de-DE";
titlePrefix = "Frage ";
break;
case 'FR':
zone = 'fr-FR';
titlePrefix = 'QCM ';
break;
case 'NL':
zone = 'nl-NL';
titlePrefix = 'MKV ';
break;
case 'DE':
zone = 'de-DE';
titlePrefix = 'Frage ';
break;
}
return { zone, titlePrefix };
};
Loading

0 comments on commit ea56da3

Please sign in to comment.