Skip to content

Commit bb73309

Browse files
committed
Add json files to ESLint configuration to enforce eol-last
1 parent afc0f81 commit bb73309

File tree

4 files changed

+61
-5
lines changed

4 files changed

+61
-5
lines changed

eslint.config.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import reactPlugin from 'eslint-plugin-react';
88
import reactHooksPlugin from 'eslint-plugin-react-hooks';
99
import vitestPlugin from 'eslint-plugin-vitest';
1010
import globals from 'globals';
11+
import jsonParser from 'jsonc-eslint-parser';
1112

1213
import tseslint from 'typescript-eslint';
1314

@@ -31,9 +32,37 @@ export default tseslint.config(
3132
'**/coverage',
3233
]
3334
},
34-
js.configs.recommended,
3535
{
36+
files: ['**/*.json'],
37+
ignores: [
38+
'src/java/**',
39+
'package-lock.json' // Just in case someone accidentally creates one
40+
],
41+
languageOptions: {
42+
parser: jsonParser,
43+
parserOptions: {
44+
// Use JSONC so that comments in JSON files don't get treated as
45+
// syntax errors
46+
jsonSyntax: 'jsonc'
47+
}
48+
},
49+
plugins: {
50+
'@stylistic': stylePlugin,
51+
},
52+
rules: {
53+
'@stylistic/eol-last': 'warn',
54+
}
55+
},
56+
{
57+
extends: [
58+
js.configs.recommended,
59+
],
3660
name: 'Global JS Rules',
61+
files: [
62+
'**/*.*js',
63+
'**/*.ts',
64+
'**/*.tsx',
65+
],
3766
languageOptions: {
3867
globals: {
3968
...globals.node,
@@ -73,13 +102,15 @@ export default tseslint.config(
73102
],
74103
}
75104
},
76-
...tseslint.configs.recommended,
77105
{
106+
extends: tseslint.configs.recommended,
78107
name: 'Global Typescript Rules',
79108
files: ['**/*.ts*'],
80109
languageOptions: {
81110
parser: tseslint.parser,
82111
parserOptions: {
112+
// Prevent the parser from going any higher in the directory tree
113+
// to find a tsconfig
83114
tsconfigRootDir: import.meta.dirname,
84115
project: true
85116
}

lib/buildtools/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bin/index.js
1+
bin/index.js

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"http-server": "^0.13.0",
6060
"husky": "^9.0.11",
6161
"jsdom": "^26.1.0",
62+
"jsonc-eslint-parser": "^2.4.0",
6263
"typescript": "^5.8.2",
6364
"typescript-eslint": "^8.33.1",
6465
"vitest": "^3.2.3",

yarn.lock

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,7 @@ __metadata:
26312631
husky: "npm:^9.0.11"
26322632
js-slang: "npm:^1.0.81"
26332633
jsdom: "npm:^26.1.0"
2634+
jsonc-eslint-parser: "npm:^2.4.0"
26342635
lodash: "npm:^4.17.21"
26352636
react: "npm:^18.3.1"
26362637
react-dom: "npm:^18.3.1"
@@ -3796,7 +3797,7 @@ __metadata:
37963797
languageName: node
37973798
linkType: hard
37983799

3799-
"acorn@npm:^8.15.0":
3800+
"acorn@npm:^8.15.0, acorn@npm:^8.5.0, acorn@npm:^8.9.0":
38003801
version: 8.15.0
38013802
resolution: "acorn@npm:8.15.0"
38023803
bin:
@@ -5902,7 +5903,7 @@ __metadata:
59025903
languageName: node
59035904
linkType: hard
59045905

5905-
"eslint-visitor-keys@npm:^3.4.3":
5906+
"eslint-visitor-keys@npm:^3.0.0, eslint-visitor-keys@npm:^3.4.1, eslint-visitor-keys@npm:^3.4.3":
59065907
version: 3.4.3
59075908
resolution: "eslint-visitor-keys@npm:3.4.3"
59085909
checksum: 10c0/92708e882c0a5ffd88c23c0b404ac1628cf20104a108c745f240a13c332a11aac54f49a22d5762efbffc18ecbc9a580d1b7ad034bf5f3cc3307e5cbff2ec9820
@@ -5995,6 +5996,17 @@ __metadata:
59955996
languageName: node
59965997
linkType: hard
59975998

5999+
"espree@npm:^9.0.0":
6000+
version: 9.6.1
6001+
resolution: "espree@npm:9.6.1"
6002+
dependencies:
6003+
acorn: "npm:^8.9.0"
6004+
acorn-jsx: "npm:^5.3.2"
6005+
eslint-visitor-keys: "npm:^3.4.1"
6006+
checksum: 10c0/1a2e9b4699b715347f62330bcc76aee224390c28bb02b31a3752e9d07549c473f5f986720483c6469cf3cfb3c9d05df612ffc69eb1ee94b54b739e67de9bb460
6007+
languageName: node
6008+
linkType: hard
6009+
59986010
"esprima@npm:^4.0.0":
59996011
version: 4.0.1
60006012
resolution: "esprima@npm:4.0.1"
@@ -7854,6 +7866,18 @@ __metadata:
78547866
languageName: node
78557867
linkType: hard
78567868

7869+
"jsonc-eslint-parser@npm:^2.4.0":
7870+
version: 2.4.0
7871+
resolution: "jsonc-eslint-parser@npm:2.4.0"
7872+
dependencies:
7873+
acorn: "npm:^8.5.0"
7874+
eslint-visitor-keys: "npm:^3.0.0"
7875+
espree: "npm:^9.0.0"
7876+
semver: "npm:^7.3.5"
7877+
checksum: 10c0/1bef9f4f12122824e1d13ef651b7a8d16cbf6995bfd08fabb81df34ff0cf57f5c1c822dd5ee7aece0575fb1351538c8c5ce86f9b94d8f41bcd3bbe2773b62db3
7878+
languageName: node
7879+
linkType: hard
7880+
78577881
"jsonschema@npm:^1.5.0":
78587882
version: 1.5.0
78597883
resolution: "jsonschema@npm:1.5.0"

0 commit comments

Comments
 (0)