Skip to content

Commit 5b6f446

Browse files
committed
Do not use removed options in pylint and allow fixing of lint errors in workflow
1 parent 4186747 commit 5b6f446

File tree

4 files changed

+49
-41
lines changed

4 files changed

+49
-41
lines changed

.github/workflows/lint_random_files.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ on:
6363
type: boolean
6464
description: Lint Python files
6565
default: true
66+
fix:
67+
type: boolean
68+
description: Automatically fix lint errors (if possible) and file a pull request
69+
default: false
6670

6771
# Trigger the workflow every 24 hours:
6872
schedule:
@@ -238,34 +242,41 @@ jobs:
238242
# Define the path to ESLint configuration file for linting benchmarks:
239243
eslint_benchmarks_conf="${root}/etc/eslint/.eslintrc.benchmarks.js"
240244
245+
# Set `FIX` variable to `1` to enable automatic fixing of lint errors, `0` to disable:
246+
if [ "${{ github.event.inputs.fix }}" == "true" ]; then
247+
FIX=1
248+
else
249+
FIX=0
250+
fi
251+
241252
# Lint JavaScript source files:
242253
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ' ' '\n' | grep '\.js$' | grep -v -e '/examples' -e '/test' -e '/benchmark' -e '^dist/' | tr '\n' ' ')
243254
if [[ -n "${files}" ]]; then
244-
make lint-javascript-files FAST_FAIL=0 FILES="${files}"
255+
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}"
245256
fi
246257
247258
# Lint JavaScript command-line interfaces...
248259
file=$(echo "${{ steps.random-files.outputs.files }}" | tr ' ' '\n' | grep '\.js$' | grep -E '/bin/cli$' | tr '\n' ' ')
249260
if [[ -n "${file}" ]]; then
250-
make lint-javascript-files FAST_FAIL=0 FILES="${file}"
261+
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${file}"
251262
fi
252263
253264
# Lint JavaScript example files:
254265
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ' ' '\n' | grep '/examples/.*\.js$' | tr '\n' ' ')
255266
if [[ -n "${files}" ]]; then
256-
make lint-javascript-files FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_examples_conf}"
267+
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_examples_conf}"
257268
fi
258269
259270
# Lint JavaScript test files:
260271
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ' ' '\n' | grep '/test/.*\.js$' | tr '\n' ' ')
261272
if [[ -n "${files}" ]]; then
262-
make lint-javascript-files FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_tests_conf}"
273+
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_tests_conf}"
263274
fi
264275
265276
# Lint JavaScript benchmark files:
266277
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ')
267278
if [[ -n "${files}" ]]; then
268-
make lint-javascript-files FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
279+
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
269280
fi
270281
271282
# Lint Python files:
@@ -361,3 +372,23 @@ jobs:
361372
if [[ -n "${files}" ]]; then
362373
make lint-license-headers-files FILES="${files}"
363374
fi
375+
376+
# Create a pull request with the fixes:
377+
- name: 'Create pull request'
378+
id: cpr
379+
uses: peter-evans/create-pull-request@v3
380+
with:
381+
title: 'Fix lint errors'
382+
body: |
383+
This PR
384+
385+
- fixes lint errors
386+
387+
commit-message: 'Fix lint errors'
388+
committer: 'stdlib-bot <noreply@stdlib.io>'
389+
labels: |
390+
automated-pr
391+
team-reviewers: |
392+
stdlib-reviewers
393+
branch: 'fix-lint-errors'
394+
delete-branch: true

etc/pylint/.pylintrc

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,46 +92,28 @@ max-nested-blocks=5
9292

9393
[BASIC]
9494

95-
# Naming hint for argument names
96-
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
97-
9895
# Regular expression matching correct argument names
9996
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
10097

101-
# Naming hint for attribute names
102-
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
103-
10498
# Regular expression matching correct attribute names
10599
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
106100

107101
# Bad variable names which should always be refused, separated by a comma
108102
bad-names=foo,bar,baz,toto,tutu,tata
109103

110-
# Naming hint for class attribute names
111-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
112-
113104
# Regular expression matching correct class attribute names
114105
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
115106

116-
# Naming hint for class names
117-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
118-
119107
# Regular expression matching correct class names
120108
class-rgx=[A-Z_][a-zA-Z0-9]+$
121109

122-
# Naming hint for constant names
123-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
124-
125110
# Regular expression matching correct constant names
126111
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
127112

128113
# Minimum line length for functions/classes that require docstrings, shorter
129114
# ones are exempt.
130115
docstring-min-length=-1
131116

132-
# Naming hint for function names
133-
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
134-
135117
# Regular expression matching correct function names
136118
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
137119

@@ -141,21 +123,12 @@ good-names=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,_
141123
# Include a hint for the correct naming format with invalid-name
142124
include-naming-hint=no
143125

144-
# Naming hint for inline iteration names
145-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
146-
147126
# Regular expression matching correct inline iteration names
148127
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
149128

150-
# Naming hint for method names
151-
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
152-
153129
# Regular expression matching correct method names
154130
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
155131

156-
# Naming hint for module names
157-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
158-
159132
# Regular expression matching correct module names
160133
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
161134

@@ -171,9 +144,6 @@ no-docstring-rgx=^_
171144
# to this list to register other decorators that produce valid properties.
172145
property-classes=abc.abstractproperty
173146

174-
# Naming hint for variable names
175-
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
176-
177147
# Regular expression matching correct variable names
178148
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
179149

@@ -199,12 +169,6 @@ max-line-length=300
199169
# Maximum number of lines in a module
200170
max-module-lines=1000
201171

202-
# List of optional constructs for which whitespace checking is disabled. `dict-
203-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
204-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
205-
# `empty-line` allows space-only lines.
206-
no-space-check=trailing-comma,dict-separator
207-
208172
# Allow the body of a class to be on the same line as the declaration if body
209173
# contains single statement.
210174
single-line-class-stmt=no

tools/make/common.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ else
4747
endif
4848
endif
4949

50+
# Indicate whether to fix linting errors:
51+
ifndef FIX
52+
FIX := false
53+
else
54+
ifeq ($(FIX), 0)
55+
FIX := false
56+
else
57+
FIX := true
58+
endif
59+
endif
5060

5161
# ENVIRONMENTS #
5262

tools/make/lib/lint/javascript/eslint.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ ESLINT_FLAGS ?= \
4949
--ignore-path $(ESLINT_IGNORE) \
5050
--report-unused-disable-directives
5151

52+
ifeq ($(FIX),true)
53+
ESLINT_FLAGS += --fix
54+
endif
5255

5356
# RULES #
5457

0 commit comments

Comments
 (0)