grunt-flake8

raw JSON →
0.1.3 verified Fri May 01 auth: no javascript deprecated

A Grunt plugin to lint Python projects using flake8, which combines PyFlakes, PEP8, and McCabe's cyclomatic complexity checks. Version 0.1.3, last released in 2014, with no active development. It wraps flake8 as a Grunt task, allowing project-level configuration overrides. Alternatives include direct flake8 invocation or other Python linters.

error Warning: Task "flake8" not found. Use --force to continue.
cause grunt.loadNpmTasks('grunt-flake8') missing or package not installed.
fix
Ensure grunt-flake8 is installed and run npm install grunt-flake8 --save-dev, then add grunt.loadNpmTasks('grunt-flake8') to Gruntfile.
error Fatal error: flake8 command not found
cause flake8 not installed in current Python environment.
fix
Install flake8 via pip: pip install flake8, and ensure the virtual environment is activated.
error Running "flake8:src" (flake8) task Warning: Task "flake8:src" failed. Use --force to continue.
cause Linting errors found and options.force is false.
fix
Set options.force: true to continue despite errors, or fix the lint issues.
deprecated Package has not been updated since 2014; unmaintained.
fix Use direct flake8 invocation or switch to modern Python linting tools.
gotcha Grunt must be run from within the Python virtual environment where flake8 is installed.
fix Activate the virtual environment before running grunt.
gotcha Options set in Gruntfile override global/project flake8 configurations; some options may be dropped silently.
fix Check flake8 documentation for supported options and test with --verbose.
npm install grunt-flake8
yarn add grunt-flake8
pnpm add grunt-flake8

Configures a flake8 Grunt task to lint Python files with custom options.

// Install: npm install grunt-flake8 --save-dev
// Gruntfile.js
module.exports = function(grunt) {
  grunt.initConfig({
    flake8: {
      options: {
        errorsOnly: false,
        force: false,
        maxComplexity: 10,
        maxLineLength: 100,
        ignore: ['E501']
      },
      src: ['src/**/*.py', 'test/**/*.py']
    }
  });
  grunt.loadNpmTasks('grunt-flake8');
  grunt.registerTask('default', ['flake8']);
};