1.1.0 • Published 3 years ago

eslint-plugin-django v1.1.0

Weekly downloads
106
License
BSD-3-Clause
Repository
github
Last release
3 years ago

eslint-plugin-django

Overview

This ESLint environment plugin provides globals for the Django JavaScript Catalog.

Most ESLint configurations use "no-undef": "error", which will cause ESLint to error if you internationalize your code and use Django as your backend, e.g.:

{# some template that loads your JS code #}
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>

… then call one of its functions in your front-end code:

const someText = gettext('My Text');

Installation

First add the plugin as a development dependency:

npm install --save-dev eslint-plugin-django

Then configure ESLint to use it:

{
  "plugins": ["django"],
  "env": {
    "browser": true,
    "node": true,
    "django/i18n": true
  }
}

Refer to the ESLint docs for configuring plugins and environments if you need more information.

Alternatives

If you don’t want to install this plugin you can list the necessary functions in the ESLint configuration globals key instead:

{
  "globals": {
    "gettext": "readonly",
    "ngettext": "readonly",
    "interpolate": "readonly",
    "get_format": "readonly",
    "gettext_noop": "readonly",
    "pgettext": "readonly",
    "npgettext": "readonly",
    "pluralidx": "readonly",
    "django": "readonly"
  }
}