Bird
Raised Fist0
Denoframework~20 mins

deno lint for code quality - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Deno Lint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Identify the lint error in this Deno code snippet

What lint error will deno lint report for the following code?

Deno
const unusedVar = 42;
console.log("Hello Deno!");
AError: 'unusedVar' is declared but its value is never read
BNo errors, code is clean
CError: Missing semicolon at the end of line 2
DError: console.log is not allowed
Attempts:
2 left
💡 Hint

Think about variables declared but never used in the code.

❓ component_behavior
intermediate
1:30remaining
Effect of linting on Deno project files

After running deno lint on a project, what is the expected behavior?

AIt reports lint errors and warnings without changing files
BIt automatically fixes all lint errors in the code
CIt deletes files with lint errors
DIt compiles the code to JavaScript
Attempts:
2 left
💡 Hint

Consider if deno lint modifies your source files or just reports issues.

🔧 Debug
advanced
2:30remaining
Diagnose the lint error from this Deno code

What specific lint error will deno lint report for this code?

Deno
function greet(name: string) {
  if(name) {
    console.log("Hello, " + name);
  }
}
greet();
ANo lint errors
BError: Missing argument in function call to 'greet'
CError: Function 'greet' is declared but never used
DError: 'name' is possibly undefined
Attempts:
2 left
💡 Hint

Check the function parameter usage and how it is called.

❓ state_output
advanced
2:00remaining
Output of deno lint with a style violation

What output will deno lint produce for this code snippet?

Deno
const message = "Hello Deno"
console.log(message)
ANo errors, code is clean
BError: 'message' is declared but never used
CError: Missing semicolon at the end of line 1
DWarning: Missing semicolon at the end of line 1
Attempts:
2 left
💡 Hint

Think about style rules like semicolons and how Deno lint reports them.

🧠 Conceptual
expert
3:00remaining
Understanding deno lint configuration impact

Given a deno.json configuration with "lint": { "rules": { "tags": ["recommended"] } }, what effect does this have on deno lint?

ALinting will be disabled completely
BLint will automatically fix all issues tagged 'recommended'
CAll lint rules except those tagged 'recommended' will be checked
DOnly lint rules tagged as 'recommended' will be checked
Attempts:
2 left
💡 Hint

Consider how specifying tags in lint rules filters which rules run.

Practice

(1/5)
1. What is the main purpose of running deno lint on your code?
easy
A. To execute the code and show output
B. To find and report code style and potential error issues
C. To compile the code into a binary
D. To install external dependencies automatically

Solution

  1. Step 1: Understand what linting means

    Linting is a process that checks code for style and possible mistakes without running it.
  2. Step 2: Identify what deno lint does

    deno lint scans your code files and reports style issues or errors to improve code quality.
  3. Final Answer:

    To find and report code style and potential error issues -> Option B
  4. Quick Check:

    Linting = Find code issues [OK]
Hint: Lint checks code style and errors, not execution or compilation [OK]
Common Mistakes:
  • Confusing lint with running or compiling code
  • Thinking lint installs dependencies
  • Assuming lint fixes all errors automatically
2. Which command correctly runs the linter on all files in the current folder and subfolders?
easy
A. deno lint --fix
B. deno run lint
C. deno lint .
D. deno lint --all

Solution

  1. Step 1: Identify the command to lint files

    The command deno lint followed by a path runs lint on that path.
  2. Step 2: Understand the meaning of '.' in commands

    Using '.' means current directory and all files inside it recursively.
  3. Final Answer:

    deno lint . -> Option C
  4. Quick Check:

    Lint current folder = deno lint . [OK]
Hint: Use dot (.) to lint current folder and subfolders [OK]
Common Mistakes:
  • Using 'deno run lint' which is invalid
  • Assuming '--all' is a valid flag for deno lint
  • Confusing '--fix' as a way to run lint only
3. Given this code snippet in example.ts:
const unusedVar = 5;
console.log("Hello Deno!");
What will deno lint example.ts report?
medium
A. Error: unused variable 'unusedVar'
B. Warning: missing semicolon
C. Syntax error on line 1
D. No issues found

Solution

  1. Step 1: Analyze the code for lint issues

    The variable unusedVar is declared but never used, which is a common lint warning.
  2. Step 2: Understand what deno lint reports

    Deno lint reports unused variables as errors or warnings to improve code quality.
  3. Final Answer:

    Error: unused variable 'unusedVar' -> Option A
  4. Quick Check:

    Unused variable = lint error [OK]
Hint: Unused variables cause lint errors, check variable usage [OK]
Common Mistakes:
  • Thinking no issues appear if code runs
  • Confusing lint errors with syntax errors
  • Expecting semicolon warnings when not configured
4. You run deno lint and get errors about unused imports. Which fix will resolve this?
medium
A. Ignore the errors and continue running the code
B. Add --fix flag to automatically remove unused imports
C. Rename the imports to different variable names
D. Remove the unused import lines from the code

Solution

  1. Step 1: Understand what unused import errors mean

    Unused imports are lines importing modules or variables that are never used in the code.
  2. Step 2: Identify the correct fix

    Removing those unused import lines cleans the code and fixes the lint errors. The --fix flag does not always remove imports automatically.
  3. Final Answer:

    Remove the unused import lines from the code -> Option D
  4. Quick Check:

    Remove unused imports to fix lint errors [OK]
Hint: Delete unused imports manually; --fix may not remove them [OK]
Common Mistakes:
  • Assuming --fix always removes unused imports
  • Ignoring lint errors thinking code still runs
  • Renaming imports without using them
5. You want to automatically fix some lint issues in your project folder. Which command should you run?
hard
A. deno lint --fix ./
B. deno lint --auto-fix ./
C. deno lint fix ./
D. deno lint --correct ./

Solution

  1. Step 1: Recall the flag for automatic fixing in deno lint

    The correct flag to fix some lint issues automatically is --fix.
  2. Step 2: Confirm the command syntax

    The command deno lint --fix ./ runs lint on the current folder and applies automatic fixes where possible.
  3. Final Answer:

    deno lint --fix ./ -> Option A
  4. Quick Check:

    Use --fix flag to auto-correct lint issues [OK]
Hint: Use --fix flag with deno lint to auto-correct issues [OK]
Common Mistakes:
  • Using incorrect flags like --auto-fix or --correct
  • Typing 'deno lint fix' without dashes
  • Not specifying the folder or file to lint
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard