CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-uglify-save-license

License detector for UglifyJS that identifies and preserves license comments during minification

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-4/

License Comment Detector

A tool that automatically detects and identifies license-related comments in JavaScript source code without requiring any configuration.

Capabilities

Detects license comments automatically

Build a comment analysis function that examines JavaScript comments and determines whether they contain license-related information. The function should work without any configuration or setup from the user.

  • Given a comment containing "MIT License", the function returns true indicating it's a license comment @test
  • Given a comment containing "Copyright (c) 2024", the function returns true indicating it's a license comment @test
  • Given a comment containing "@preserve", the function returns true indicating it's a license comment @test
  • Given a regular code comment like "This is a helper function", the function returns false @test
  • Given a comment on line 1 of a file with text "Main module", the function returns true indicating it's preserved as a first-line comment @test

Implementation

@generates

API

/**
 * Determines whether a comment should be preserved based on license-related heuristics.
 * Works automatically without requiring any configuration.
 *
 * @param {Object} node - AST node from the parser
 * @param {Object} comment - Comment information object
 * @param {string} comment.file - Current file path being processed
 * @param {string} comment.type - Comment type ('comment1' for line comment, 'comment2' for block comment)
 * @param {string} comment.value - The text content of the comment
 * @param {number} comment.line - Line number where the comment appears
 * @returns {boolean} true if the comment should be preserved, false otherwise
 */
function shouldPreserveComment(node, comment) {
  // IMPLEMENTATION HERE
}

module.exports = shouldPreserveComment;

Dependencies { .dependencies }

uglify-save-license { .dependency }

Provides automatic license comment detection and preservation logic for use with minification tools.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-uglify-save-license

tile.json