JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q20924F
  • License MIT

generate an .eslintrc against a legacy codebase

Package Exports

  • eslint-lockdown

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-lockdown) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

eslint-lockdown

generate an .eslintrc against a legacy codebase

usage

$ npm i -g eslint-lockdown
$ eslint-lockdown

eslint-lockdown will generate an .eslintrc to utilize eslint against a legacy codebase. It reads in your (optional) current .eslintrc file and generates a new .eslintrc with failing rules marked as warn. This allows you to "put a stake in the ground" to prevent your code getting worse, utilizing eslint as part of your build process without halting development.

By default, eslint-lockdown will overwrite the .eslintrc file. To preview the results without overwriting:

$ eslint-lockdown --debug

example

This snippet, foo.js:

module.exports = function() {
    var unused = true;
    console.log("foobar");
}

violates many eslint:recommended rules:

$ eslint foo.js

/foo/bar/foo.js
  1:1  error  "module" is not defined             no-undef
  2:9  error  "unused" is defined but never used  no-unused-vars
  3:5  error  Unexpected console statement        no-console
  3:5  error  "console" is not defined            no-undef

✖ 4 problems (4 errors, 0 warnings)

Running eslint-lockdown, we would generate an .eslintrc file to make eslint pass:

{
    "extends": "eslint:recommended",
    "rules": {
        "no-undef": [ 1 ],
        "no-unused-vars": [ 1 ],
        "no-console": [ 1 ]
    }
}

After generating the new file, eslint will pass with warnings:

$ eslint .

/Users/john/mysrc/weisjohn/scratch/eslint_lockdown/index.js
  1:1  warning  "module" is not defined             no-undef
  2:9  warning  "unused" is defined but never used  no-unused-vars
  3:5  warning  Unexpected console statement        no-console
  3:5  warning  "console" is not defined            no-undef

✖ 4 problems (0 errors, 4 warnings)

library

If you want to further wrangle the configuration, you can use eslint-lockdown as a node library:

var lockdown = require('eslint-lockdown');

lockdown(__dirname, function(err, config) {
    if (err) return console.error(err);
    console.log(config);
});