0
0
mirror of https://github.com/django/django.git synced 2024-11-21 10:59:04 +01:00

Migrated to ESLint 9+.

This commit is contained in:
Mariusz Felisiak 2024-05-05 21:03:16 +02:00 committed by Sarah Boyce
parent 9a27c76021
commit 6345a6ff63
11 changed files with 71 additions and 52 deletions

View File

@ -1,7 +0,0 @@
**/*.min.js
**/vendor/**/*.js
django/contrib/gis/templates/**/*.js
django/views/templates/*.js
docs/_build/**/*.js
node_modules/**.js
tests/**/*.js

View File

@ -1,37 +0,0 @@
{
"rules": {
"camelcase": ["off", {"properties": "always"}],
"comma-spacing": ["error", {"before": false, "after": true}],
"curly": ["error", "all"],
"dot-notation": ["error", {"allowKeywords": true}],
"eqeqeq": ["error"],
"indent": ["error", 4],
"key-spacing": ["error", {"beforeColon": false, "afterColon": true}],
"linebreak-style": ["error", "unix"],
"new-cap": ["off", {"newIsCap": true, "capIsNew": true}],
"no-alert": ["off"],
"no-eval": ["error"],
"no-extend-native": ["error", {"exceptions": ["Date", "String"]}],
"no-multi-spaces": ["error"],
"no-octal-escape": ["error"],
"no-script-url": ["error"],
"no-shadow": ["error", {"hoist": "functions"}],
"no-underscore-dangle": ["error"],
"no-unused-vars": ["error", {"vars": "local", "args": "none"}],
"no-var": ["error"],
"prefer-const": ["error"],
"quotes": ["off", "single"],
"semi": ["error", "always"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}],
"space-infix-ops": ["error", {"int32Hint": false}],
"strict": ["error", "global"]
},
"env": {
"browser": true,
"es6": true
},
"globals": {
"django": false
}
}

View File

@ -20,6 +20,6 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.56.0
rev: v9.2.0
hooks:
- id: eslint

View File

@ -1,4 +1,4 @@
/*global SelectBox, gettext, interpolate, quickElement, SelectFilter*/
/*global SelectBox, gettext, ngettext, interpolate, quickElement, SelectFilter*/
/*
SelectFilter2 - Turns a multiple-select box into a filter interface.

View File

@ -1,4 +1,4 @@
/*global gettext, interpolate, ngettext*/
/*global gettext, interpolate, ngettext, Actions*/
'use strict';
{
function show(selector) {

View File

@ -1,4 +1,3 @@
/*global opener */
'use strict';
{
const initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse);

View File

@ -54,7 +54,7 @@ class MapWidget {
// Altering using user-provided options
for (const property in options) {
if (options.hasOwnProperty(property)) {
if (Object.hasOwn(options, property)) {
this.options[property] = options[property];
}
}

63
eslint.config.mjs Normal file
View File

@ -0,0 +1,63 @@
import globals from "globals";
import js from "@eslint/js";
export default [
js.configs.recommended,
{
files: ["**/*.js"],
rules: {
"camelcase": ["off", {"properties": "always"}],
"comma-spacing": ["error", {"before": false, "after": true}],
"curly": ["error", "all"],
"dot-notation": ["error", {"allowKeywords": true}],
"eqeqeq": ["error"],
"indent": ["error", 4],
"key-spacing": ["error", {"beforeColon": false, "afterColon": true}],
"linebreak-style": ["error", "unix"],
"new-cap": ["off", {"newIsCap": true, "capIsNew": true}],
"no-alert": ["off"],
"no-eval": ["error"],
"no-extend-native": ["error", {"exceptions": ["Date", "String"]}],
"no-multi-spaces": ["error"],
"no-octal-escape": ["error"],
"no-script-url": ["error"],
"no-shadow": ["error", {"hoist": "functions"}],
"no-underscore-dangle": ["error"],
"no-unused-vars": ["error", {"vars": "local", "args": "none"}],
"no-var": ["error"],
"prefer-const": ["error"],
"quotes": ["off", "single"],
"semi": ["error", "always"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}],
"space-infix-ops": ["error", {"int32Hint": false}],
"strict": ["error", "global"]
},
languageOptions: {
ecmaVersion: 6,
sourceType: "script",
globals: {
...globals.browser,
...globals.commonjs,
"django": false
}
}
},
{
files: ["**/*.mjs"],
languageOptions: {
sourceType: "module"
}
},
{
ignores: [
"**/*.min.js",
"**/vendor/**/*.js",
"django/contrib/gis/templates/**/*.js",
"django/views/templates/*.js",
"docs/_build/**/*.js",
"node_modules/**.js",
"tests/**/*.js",
]
}
];

View File

@ -1,4 +1,4 @@
/* global QUnit */
/* global QUnit, Actions */
'use strict';
QUnit.module('admin.actions', {

View File

@ -1,4 +1,4 @@
/* global QUnit */
/* global QUnit, initSidebarQuickFilter */
'use strict';
QUnit.module('admin.sidebar: filter', {

View File

@ -9,8 +9,9 @@
"npm": ">=1.3.0"
},
"devDependencies": {
"eslint": "^8.56.0",
"eslint": "^9.2.0",
"puppeteer": "^22.2.0",
"globals": "^15.1.0",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^8.0.1",