eslint-config-nodejs-pmb 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/rules.js +1 -0
- package/util/massfix_missing_import_fext.sh +27 -5
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{ "name": "eslint-config-nodejs-pmb",
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.3",
|
|
3
3
|
"description": "My favorite eslint rules",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"absdir": "^1.0.6",
|
|
30
|
-
"eslint-plugin-json-light-pmb": "^1.0.
|
|
30
|
+
"eslint-plugin-json-light-pmb": "^1.0.7",
|
|
31
31
|
"eslint-plugin-node": "^11.1.0",
|
|
32
32
|
"p-fatal": "^0.1.3",
|
|
33
33
|
"safe-sortedjson": "^1.0.6",
|
|
34
34
|
"usnam-pmb": "^0.2.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"eslint": "^8.
|
|
37
|
+
"eslint": "^8.12.0"
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
"npm vs. BOM = Unexpected token": "-*- coding: UTF-8 -*-"
|
package/rules.js
CHANGED
|
@@ -10,16 +10,33 @@ function addfexts () {
|
|
|
10
10
|
exec < <(eslint --ext js,mjs . | sed -urf <(echo '
|
|
11
11
|
s~^ *([0-9]+):[0-9]+ +error +Missing file extension "(\S+)" for "(\S+|$\
|
|
12
12
|
)" +import/extensions$~!:missfext \2 \3 \1~
|
|
13
|
+
s~^ *1:1 +error +Use the global form of \x27use strict\x27 strict$|$\
|
|
14
|
+
~!global_use_strict~
|
|
13
15
|
')) || return $?
|
|
14
|
-
local
|
|
16
|
+
local ABS_PWD="$(readlink -m .)"
|
|
17
|
+
local LN=
|
|
18
|
+
local SRC_FN=
|
|
19
|
+
local ERR_CNT_IN_FILE=
|
|
15
20
|
while IFS= read -r LN; do
|
|
16
21
|
case "$LN" in
|
|
17
22
|
'' ) continue;;
|
|
18
|
-
/*.
|
|
23
|
+
/*.js | \
|
|
24
|
+
/*.mjs )
|
|
25
|
+
LN="${LN#"$ABS_PWD/"}"
|
|
26
|
+
SRC_FN="$LN"
|
|
27
|
+
ERR_CNT_IN_FILE=0
|
|
28
|
+
continue;;
|
|
19
29
|
'!:missfext '* )
|
|
20
30
|
LN="${LN#*:}"
|
|
21
31
|
fix_"${LN%% *}" "${LN#* }" || return $?;;
|
|
22
|
-
|
|
32
|
+
!global_use_strict )
|
|
33
|
+
LANG=C sed -re '1s~^(\xEF\xBB\xBF|)~&\x27use strict\x27;\n~' \
|
|
34
|
+
-i -- "$SRC_FN" || return $?;;
|
|
35
|
+
* )
|
|
36
|
+
[ "$ERR_CNT_IN_FILE" == 0 ] && echo "W: In file '$SRC_FN':" >&2
|
|
37
|
+
(( ERR_CNT_IN_FILE += 1 ))
|
|
38
|
+
echo "W: eslint says: '$LN'" >&2
|
|
39
|
+
;;
|
|
23
40
|
esac
|
|
24
41
|
done
|
|
25
42
|
}
|
|
@@ -30,8 +47,13 @@ function fix_missfext () {
|
|
|
30
47
|
local FEXT="${ARG%% *}"; ARG="${ARG#* }"
|
|
31
48
|
local REF="${ARG%% *}"; ARG="${ARG#* }"
|
|
32
49
|
local LNUM="$ARG"
|
|
33
|
-
echo "D: Add fext .$FEXT to $SRC_FN line $LNUM:"
|
|
34
|
-
|
|
50
|
+
echo "D: Add fext .$FEXT to file '$SRC_FN' line $LNUM:"
|
|
51
|
+
local SED=(
|
|
52
|
+
sed -re
|
|
53
|
+
"$LNUM"'s~(\x27|\x22)\)?;?$~.'"$FEXT"'&~'
|
|
54
|
+
-i -- "$SRC_FN"
|
|
55
|
+
)
|
|
56
|
+
"${SED[@]}" || return $?$(echo "W: sed failed, rv=$?" >&2)
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
|