Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .eslintignore
Empty file.
37 changes: 0 additions & 37 deletions .eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Agent Notes

## Scope

- This repository is a Node.js/TypeScript library.
- Only work in `src/` and `test/` unless explicitly asked to do otherwise.
- Treat all changes as security-sensitive; this library is foundational for other security-focused projects (e.g., `node-saml`).

## Conventions

- Keep changes minimal and focused.
- Prefer defensive coding and preserve existing security properties.
- Follow existing project style and lint rules.
- Don't edit `node_modules/`.

## Verification

- After all changes, run:
- `npm run build && npm test && npm run lint:fix`
62 changes: 62 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const js = require("@eslint/js");
const tseslint = require("typescript-eslint");
const globals = require("globals");
const prettierConfig = require("eslint-config-prettier");
const simpleImportSort = require("eslint-plugin-simple-import-sort");

module.exports = tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ["**/*.ts"],
plugins: {
"simple-import-sort": simpleImportSort,
},
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
globals: {
...globals.node,
...globals.mocha,
...globals.es2020,
Attr: "readonly",
ChildNode: "readonly",
Comment: "readonly",
Document: "readonly",
Element: "readonly",
Node: "readonly",
XPathNSResolver: "readonly",
},
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-console": "error",
"no-prototype-builtins": "error",
"one-var": ["error", "never"],
"no-duplicate-imports": "error",
"no-use-before-define": "error",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "eslint.config.js" -type f

Repository: node-saml/xml-crypto

Length of output: 82


🏁 Script executed:

cat -n eslint.config.js

Repository: node-saml/xml-crypto

Length of output: 2235


🏁 Script executed:

head -50 eslint.config.js | cat -n

Repository: node-saml/xml-crypto

Length of output: 1979


🏁 Script executed:

wc -l eslint.config.js && head -62 eslint.config.js | cat -n

Repository: node-saml/xml-crypto

Length of output: 2255


🌐 Web query:

no-use-before-define vs @typescript-eslint/no-use-before-define TypeScript

💡 Result:

What’s the difference?

no-use-before-define (ESLint core)

  • The built-in ESLint rule that flags using identifiers before they’re declared (variables, functions, classes, etc.). (eslint.org)

@typescript-eslint/no-use-before-define (TypeScript-ESLint)

  • A TypeScript-aware version that extends the ESLint core rule to better handle TypeScript syntax/semantics. (typescript-eslint.io)

Which should you use in TypeScript?

  • In TypeScript projects, the common guidance is: turn off the ESLint core rule and turn on @typescript-eslint/no-use-before-define, to avoid incorrect reports and ensure TS syntax is handled properly. (typescript-eslint.io)

Typical config

// .eslintrc.cjs / .eslintrc.js
module.exports = {
  rules: {
    "no-use-before-define": "off",
    "@typescript-eslint/no-use-before-define": "error",
  },
};

(typescript-eslint.io)

Citations:


Use the TypeScript-aware no-use-before-define rule.

The core ESLint rule cannot properly handle TypeScript syntax and semantics, causing incorrect or noisy lint failures. Replace it with @typescript-eslint/no-use-before-define.

Proposed fix
-      "no-use-before-define": "error",
+      "no-use-before-define": "off",
+      "@typescript-eslint/no-use-before-define": "error",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"no-use-before-define": "error",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eslint.config.js` at line 41, Replace the core ESLint rule
"no-use-before-define" with the TypeScript-aware
"@typescript-eslint/no-use-before-define" in the config: remove or disable
"no-use-before-define" and add "@typescript-eslint/no-use-before-define":
"error" (or desired setting) so TypeScript syntax is handled correctly; update
any rule ordering or plugin entries if needed to ensure "@typescript-eslint"
rules are applied.

curly: "error",
eqeqeq: ["error", "smart"],
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error",
"@typescript-eslint/no-deprecated": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-this-alias": "error",
},
},
{
files: ["test/**/*.ts"],
rules: {
"@typescript-eslint/no-unused-expressions": "off",
},
},
{
rules: prettierConfig.rules,
},
);
Loading