Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@nevware21/grunt-eslint-ts

nevware211.3k0.5.1

ESLint TypeScript Validation Plugin for GruntJS

grunt, gruntplugin, typescript, task

readme

@Nevware21/grunt-eslint-ts

GitHub Workflow Status (main) npm version downloads

Grunt-eslint-ts provides a Grunt-compatible wrapper for running eslint using the @typescript-eslint parser for processing TypeScript files, and provides some additional options that improves the TypeScript development workflow.

Grunt-eslint-ts-plugin Features

TBD...

Unsupported Grunt features

  • Path Mapping feature as it is not supported by tsc from the command-line
  • Grunt dest target property, use the src options instead.
  • Grunt files property for identifying files to be compiled (*.ts), planned future feature (#18 - [Feature] Add support for Grunt files object)

Quickstart

Install the npm packare: npm install @nevware21/grunt-eslint-ts --save-dev

Package Descriptpion
ESLint npm install eslint --save-dev - if you don't have ESLint installed in your project, run
@typescript-eslint/eslint-plugin npm install @typescript-eslint/eslint-plugin --save-dev - if you don't have the @typescript plugin installed
@typescript-eslint/parser npm install @typescript-eslint/parser --save-dev - if you dont have the parser installed
eslint-plugin-security (Optional) npm install eslint-plugin-security --save-dev - If you want to auto inject the extra security plugin
TypeScript npm install typescript --save-dev - if you don't have TypeScript installed in your project, run
GruntJS npm install grunt --save-dev - if you don't have GruntJS installed in your project
Grunt-Cli npm install grunt-cli --save-dev - Suggested, if you have never used Grunt on your system

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

Mininimal

module.exports = function(grunt) {
  grunt.initConfig({
    lint: {
      default : {
        tsconfig: './tsconfig.json'
      }
    }
  });
  grunt.loadNpmTasks("@nevware21/grunt-eslint-ts");
  grunt.registerTask("default", ["lint"]);
};

Options

The options can be specified at the global options, task options or directly on the task level, with the task level values overridding any value defined in the global options

Task only level options

Name Type Description
ignoreFailures boolean Ignore failures and continue, useful for initial linting runs for mono-repo's

Common options: Global and Task

Name Type Description
parser IESLintParser Override the parser and plugin to use, defaults to { plugin: "@typescript-eslint"; name: "@typescript-eslint/parser" }, set to null to block the defaults from getting injected
additionalConfig Linter.Config Additional Config that will be used to override the base Configuration, any additionalConfig will override any defaults
rules Linter.RulesRecord Additional specific rules to pass as overrides
logOutput boolean Log the output (stdout, stderr) of the execute command eslint response
suppressWarnings boolean Only include errors in the output
fix boolean Fix all fixable errors and warnings
disableOutputFixes boolean When automatic fixes are request and found, ignore the fix and don't output the fixed version, useful for debugging specific fixes that don't seem correct and you have automatic fixing enabled by default
debug boolean Log additional debug messages some are only display with grunt verbose messages enabled
quiet boolean Don't output the report to the console / grunt output
outputFile string Output the results to the provided file
format string Specify the format of the eslint report, defaults to codeframe
tsconfig string The path to the tsConfig file to use, when specified
maxWarnings number If more than this number of warnings are reported failed the task
src string string[]

IEsLintParser

Name Type Description
name string The name of the parser to use for the eslint configuration, defaults to @typescript-eslint/parser if the @typescript-eslint/parser package exists in the node_modules
plugins string | string[] The plugin(s) to include for the eslint configuration, defaults to @typescript-eslint if the @typescript-eslint parser / plugin package exists in the node_modules, when the plugin is detected this also injects the plugin:@typescript-eslint/recommended rules extension (This may change in a future release to be a configuration).
parserOptions Linter.ParserOptions Additional parser options to apply for the eslint configuration

eslint-plugin-security

When the eslint-plugin-security package is detected in the node_modules this will be automatically injected into the eslint configuration during linting with the plugin:security/recommended rules. (This may change in a future release to be a configuration)

Example showing some option combinations

module.exports = function(grunt) {
  grunt.initConfig({
    "lint": {
        options: {
            format: "codeframe",
            suppressWarnings: false,
            debug: true,
            logOutput: true,
            failNoFiles: false          // Defaults to `true` linting will fail if no files are configured
        },
        "shared": {
            tsconfig: "./shared/tsconfig.json",
            ignoreFailures: true,
            src: [
                // Adds extra source files above those listed in the tsconfig.json
                './shared/src/**/*.ts'
            ]
        },
        "ts_plugin": {
            tsconfig: "./ts-plugin/tsconfig.json",
            ignoreFailures: true
        },
        "eslint_ts": {
            tsconfig: "./eslint-ts-plugin/tsconfig.json",
            ignoreFailures: true
        },
        "shared-fix": {
            // You can specify the options, either in an options object like there or directly in the task
            // definition like those above
            options: {
                tsconfig: "./shared/tsconfig.json",
                fix: true,
                src: [
                    './shared/src/**/*.ts'
                ]                
            }
        },
        "ts_plugin-fix": {
            options: {
                tsconfig: "./ts-plugin/tsconfig.json",
                fix: true
            }
        },
        "eslint_ts-fix": {
            options: {
                tsconfig: "./eslint-ts-plugin/tsconfig.json",
                fix: true,
            }
        }
    }
  });

  grunt.loadNpmTasks("@nevware21/grunt-eslint-ts");
  grunt.registerTask("dolint", [ "lint:shared", "lint:ts_plugin", "lint:eslint_ts" ]);
  grunt.registerTask("lint-fix", [ "lint:shared-fix", "lint:ts_plugin-fix", "lint:eslint_ts-fix" ]);
};

Version 0.1.0 used a taskname of eslint-ts, while 0.2.0 changes the primary taskname to lint but includes an alias task eslint-ts for backward compatibility. Will likely be removed prior to v1.0.0.

Contributing

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

Release History

See The ChangeLog

changelog

v0.5.1 (Sept 2nd, 2024)

Changelog

  • 271 [BUG] eslint ignoreFailures is not ignoring all failures

    • Now merges files and include from the tsconfig
    • Added more debug logging
    • Add fileNoFiles (defaults to true)

v0.5.0 (July 21st, 2024)

Bumping to 0.5.0 to align with the changes for grunt ts plugin to support inlining the tsconfig.

Changelog

  • 44 [Feature] Add support to inlining the tsconfig.json within the grunt config

  • 254 [Feature] Add Support for multiple tsconfigs

  • 259 Bump @nevware21 gunt plugins to latest

v0.2.5 (July 4th, 2024)

Changelog

  • Update build script to support release automation (#258)
  • 15 [Work Item] ts-plugin: Add test coverage

  • Bump @types/estree from 0.0.51 to 0.0.52
  • Bump @nevware21/ts-utils from 0.1.1 to 0.2.0 (#106)
  • Bump @nevware21/ts-utils from 0.1.1 to 0.2.0 in /shared; /ts-plugin and /eslint-ts-plugin (#108)
  • Bump @nevware21/ts-utils from 0.2.0 to 0.3.0 (#113)
  • Update ts-utils to v0.3.0 (#115)
    • Update rush to 5.75.0
    • Update npm to 8.15.0
  • Update ts-utils; npm and rush versions (#124)
  • Bump @rollup/plugin-node-resolve from 13.3.0 to 14.1.0 (#135)
  • Update ts-utils to 0.5.0 (#151)
  • Bump @nevware21/ts-utils from 0.5.0 to 0.6.0 (#174)
  • Bump @rollup/plugin-commonjs from 22.0.2 to 23.0.3 (#175)
    • Bump rush to 5.86.0
    • Bump npm to 8.19.3
    • Add node 18 to CI tests
  • Bump @rollup/plugin-json from 4.1.0 to 5.0.2 (#176)
  • Bump @rollup/plugin-commonjs from 23.0.7 to 24.0.0 (#184)
  • Bump typescript to 4.9.4 (#189)
  • Bump @microsoft/rush to 5.88.0
  • Bump rollup to 3.8.1
  • Bump @rollup/plugin-commonjs to 24.0.0
  • Bump @rollup/plugin-node-resolve to 15.0.1
  • Bump @rollup/plugin-json to 6.0.0
  • Bump @typescript-esline/esline-plugin to 5.47.0
  • Bump @typescript-esline/parser tp 5.47.0
  • Bump @types/eslint to 8.4.10
  • Bump @types/estree to 1.0.0
  • Bump @nevware/ts-utils to 0.7.0 (#195)
  • Update img.shields.io build status URL's (#196)
  • Update to use ts-async and update to latest versions (#197)
  • Bump @rollup/plugin-commonjs from 24.1.0 to 25.0.0 (#207)
    • Bump @types/estree from 0.0.52 to 1.0.1
  • Bump @typescript-eslint/eslint-plugin from 5.62.0 to 6.1.0 (#210)
  • Bump rollup from 3.29.4 to 4.6.0 (#225)
    • Bump rush from 5.82.1 to 5.112.0
  • Update actions (#227)
  • [Work Item] ts-plugin: Add test coverage #15 (#226)
  • Update Copyright message to conform with LLC operating agreement (#248)
    • Fix compile issues
  • Bump @typescript-eslint/parser from 6.21.0 to 7.14.1 (#249)
  • Bump nyc from 15.1.0 to 17.0.0 (#250)
  • Bump @nevware21/ts-utils from 0.11.1 to 0.11.3 (#251)
  • Bump @nevware21/ts-async from 0.5.0 to 0.5.2
  • Bump @microsoft/rush from 5,112.0 to 5.129.6 (#252)
  • Bump chai from 4.3.6 to 4.4.1 (#253)
  • Bump mocha from 10.0.0 to 10.5.2
  • Bump sinon from 15.0.0 to 18.0.0
  • Fix issue with temp files not getting deleted (#256)

v0.2.4 (May 30th, 2022)

Changelog

  • [BUG] Latest versions grunt-ts-plugin-0.4.4 and grunt-eslint-ts-0.2.3 sometimes complain about missing @nevware21/ts-utils #97

v0.2.3

Changelog

  • Update Dependencies
  • Consume @nevware21/ts-utils for common functions

v0.2.2

Changelog

  • 66 [Bug] eslint-ts-plugin v0.2.1 - Automatic fix is not always working

v0.2.1

Changelog

  • Fixup eslint-ts task alias introduced in v0.2.0
  • Also add eslint task alias

v0.2.0

Changelog

  • Rename grunt task to lint from eslint-ts keeping an alias for eslint-ts
  • Use updated tsconfig.json to handle (ignore) included comments and trailing comma after last element for an object

v0.1.0

Changelog

  • Initial working implementation

v0.0.1

Changelog

  • Empty implementation to support self bootstrapping version