cornucopia icon indicating copy to clipboard operation
cornucopia copied to clipboard

Integrate the ts-standard for cornucopia.owasp.org

Open sydseter opened this issue 8 months ago • 13 comments

Implement TypeScript Style Guide, with linter and automatic code fixer: https://github.com/standard/ts-standard

sydseter avatar Mar 17 '26 11:03 sydseter

@sydseter can i work on this?

Adarshkumar0509 avatar Mar 17 '26 11:03 Adarshkumar0509

Hi, @sydseter! It seems there are several issues today. I would like to take this if unassigned!

ayman-art avatar Mar 17 '26 12:03 ayman-art

@Adarshkumar0509 I have assigned you. Thank you for your time.

sydseter avatar Mar 17 '26 13:03 sydseter

@sydseter ts-standard 12.x only supports TypeScript <5.2.0 but the project uses 5.9.3, causing a crash. Should I use eslint-config-love (the recommended replacement) or downgrade TypeScript?

Adarshkumar0509 avatar Mar 17 '26 19:03 Adarshkumar0509

We can do eslint-config-love

sydseter avatar Mar 18 '26 06:03 sydseter

The next step would be to integrate the linter into the build pipeline like this: eslint@^9 @eslint/js@^9 pnpm install --save-dev eslint-config-love eslint-plugin-svelte svelte-eslint-parser eslint@^9 @eslint/js@^9 typescript-eslint eslint-plugin-svelte globals @typescript-eslint/parser

"scripts": { "lint": "eslint .", "build": "svelte-kit sync && npm run lint && vite build && node ./script/headers.js && npx svelte-sitemap --domain https://cornucopia.owasp.org --ignore 404 --ignore cards/COM* --ignore cards/DVE* --ignore cards/AC* --ignore cards/CO*" }

sydseter avatar Mar 19 '26 08:03 sydseter

You need to run

npx eslint . --fix

After installing to ensure everything gets cleaned up. It's a lot. Sorry for this, but it's very needed.

After that, there is a lot of manual work as well.

sydseter avatar Mar 19 '26 08:03 sydseter

ChatGPT would probably be able to clean it up for you if you have the possibility to use it. Remember to disclose how you use it in the pull-request.

sydseter avatar Mar 19 '26 09:03 sydseter

@sydseter sir definitely i will do.

Adarshkumar0509 avatar Mar 19 '26 09:03 Adarshkumar0509

I see 73 svelte/no-navigation-without-resolve errors split into two types: 1st ione is 13 are goto() calls without await/resolve, I can fix these in code and 2nd one is 60 are plain href links flagged by the rule — should these be fixed in code or should this rule be configured differently for static links?

Adarshkumar0509 avatar Apr 14 '26 19:04 Adarshkumar0509

What rule flags the links?

sydseter avatar Apr 14 '26 20:04 sydseter

@sydseter The rule svelte/no-navigation-without-resolve from eslint-plugin-svelte is flagging both goto() calls.

Adarshkumar0509 avatar Apr 15 '26 02:04 Adarshkumar0509