Skip to content

Commit be22aa3

Browse files
authored
Update eslint rules to avoid importing MUI icons (#159)
* Bump eslint to v8 and add rule on Mui icons import * Move liniting rules and ignore to their own config files
1 parent c310f16 commit be22aa3

File tree

8 files changed

+293
-224
lines changed

8 files changed

+293
-224
lines changed

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
tests
6+
**/__tests__
7+
ui-tests

.eslintrc.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: 'tsconfig.json',
11+
sourceType: 'module'
12+
},
13+
plugins: ['@stylistic', '@typescript-eslint'],
14+
rules: {
15+
'@typescript-eslint/naming-convention': [
16+
'error',
17+
{
18+
selector: 'interface',
19+
format: ['PascalCase'],
20+
custom: {
21+
regex: '^I[A-Z]',
22+
match: true
23+
}
24+
}
25+
],
26+
'@typescript-eslint/no-unused-vars': [
27+
'warn',
28+
{
29+
args: 'none'
30+
}
31+
],
32+
'@typescript-eslint/no-explicit-any': 'off',
33+
'@typescript-eslint/no-namespace': 'off',
34+
'@typescript-eslint/no-use-before-define': 'off',
35+
'@stylistic/quotes': [
36+
'error',
37+
'single',
38+
{
39+
avoidEscape: true,
40+
allowTemplateLiterals: false
41+
}
42+
],
43+
curly: ['error', 'all'],
44+
eqeqeq: 'error',
45+
'no-restricted-imports': [
46+
'error',
47+
{
48+
paths: [
49+
{
50+
name: '@mui/icons-material',
51+
message:
52+
"Please import icons using path imports, e.g. `import AddIcon from '@mui/icons-material/Add'`"
53+
}
54+
],
55+
patterns: [
56+
{
57+
group: ['@mui/*/*/*'],
58+
message: '3rd level imports in mui are considered private'
59+
}
60+
]
61+
}
62+
],
63+
'prefer-arrow-callback': 'error'
64+
}
65+
};

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"arrowParens": "avoid",
5+
"endOfLine": "auto",
6+
"overrides": [
7+
{
8+
"files": "package.json",
9+
"options": {
10+
"tabWidth": 2
11+
}
12+
}
13+
]
14+
}

.stylelintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": [
3+
"stylelint-config-recommended",
4+
"stylelint-config-standard",
5+
"stylelint-prettier/recommended"
6+
],
7+
"plugins": [
8+
"stylelint-csstree-validator"
9+
],
10+
"rules": {
11+
"csstree/validator": true,
12+
"property-no-vendor-prefix": null,
13+
"selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$",
14+
"selector-no-vendor-prefix": null,
15+
"value-no-vendor-prefix": null
16+
}
17+
}

package.json

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@
4545
"test": "lerna run test"
4646
},
4747
"devDependencies": {
48-
"@typescript-eslint/eslint-plugin": "^6.1.0",
49-
"@typescript-eslint/parser": "^6.1.0",
50-
"eslint": "^8.36.0",
48+
"@stylistic/eslint-plugin": "^3.0.1",
49+
"@typescript-eslint/eslint-plugin": "^8.0.0",
50+
"@typescript-eslint/parser": "^8.0.0",
51+
"eslint": "^8.56.0",
5152
"eslint-config-prettier": "^8.8.0",
5253
"eslint-plugin-prettier": "^5.0.0",
5354
"lerna": "^6.4.1",
@@ -59,99 +60,5 @@
5960
"stylelint-csstree-validator": "^3.0.0",
6061
"stylelint-prettier": "^4.0.0"
6162
},
62-
"eslintIgnore": [
63-
"node_modules",
64-
"dist",
65-
"coverage",
66-
"**/*.d.ts",
67-
"tests",
68-
"**/__tests__",
69-
"ui-tests"
70-
],
71-
"eslintConfig": {
72-
"extends": [
73-
"eslint:recommended",
74-
"plugin:@typescript-eslint/eslint-recommended",
75-
"plugin:@typescript-eslint/recommended",
76-
"plugin:prettier/recommended"
77-
],
78-
"parser": "@typescript-eslint/parser",
79-
"parserOptions": {
80-
"project": "tsconfig.json",
81-
"sourceType": "module"
82-
},
83-
"plugins": [
84-
"@typescript-eslint"
85-
],
86-
"rules": {
87-
"@typescript-eslint/naming-convention": [
88-
"error",
89-
{
90-
"selector": "interface",
91-
"format": [
92-
"PascalCase"
93-
],
94-
"custom": {
95-
"regex": "^I[A-Z]",
96-
"match": true
97-
}
98-
}
99-
],
100-
"@typescript-eslint/no-unused-vars": [
101-
"warn",
102-
{
103-
"args": "none"
104-
}
105-
],
106-
"@typescript-eslint/no-explicit-any": "off",
107-
"@typescript-eslint/no-namespace": "off",
108-
"@typescript-eslint/no-use-before-define": "off",
109-
"@typescript-eslint/quotes": [
110-
"error",
111-
"single",
112-
{
113-
"avoidEscape": true,
114-
"allowTemplateLiterals": false
115-
}
116-
],
117-
"curly": [
118-
"error",
119-
"all"
120-
],
121-
"eqeqeq": "error",
122-
"prefer-arrow-callback": "error"
123-
}
124-
},
125-
"prettier": {
126-
"singleQuote": true,
127-
"trailingComma": "none",
128-
"arrowParens": "avoid",
129-
"endOfLine": "auto",
130-
"overrides": [
131-
{
132-
"files": "package.json",
133-
"options": {
134-
"tabWidth": 2
135-
}
136-
}
137-
]
138-
},
139-
"stylelint": {
140-
"extends": [
141-
"stylelint-config-recommended",
142-
"stylelint-config-standard",
143-
"stylelint-prettier/recommended"
144-
],
145-
"plugins": [
146-
"stylelint-csstree-validator"
147-
],
148-
"rules": {
149-
"csstree/validator": true,
150-
"property-no-vendor-prefix": null,
151-
"selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$",
152-
"selector-no-vendor-prefix": null,
153-
"value-no-vendor-prefix": null
154-
}
155-
},
15663
"packageManager": "[email protected]"
15764
}

packages/jupyter-chat/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface INewMessage {
7474
/**
7575
* An empty interface to describe optional settings that could be fetched from server.
7676
*/
77-
export interface ISettings {}
77+
export interface ISettings {} /* eslint-disable-line @typescript-eslint/no-empty-object-type */
7878

7979
/**
8080
* The autocomplete command type.

packages/jupyterlab-chat/src/token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface IWidgetConfig {
7878
/**
7979
* A signal emitting when the configuration for the chats has changed.
8080
*/
81-
export interface IConfigChanged
81+
export interface IConfigChanged /* eslint-disable-line @typescript-eslint/no-empty-object-type */
8282
extends ISignal<IWidgetConfig, Partial<ILabChatConfig>> {}
8383

8484
/**

0 commit comments

Comments
 (0)