summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2024-09-20 16:27:42 +0200
committerOskar <oskar@mullvad.net>2024-09-24 13:18:18 +0200
commit659aa11f05ae2b278eef6ab0ef5bc537e756109a (patch)
tree1577dc91e9134f78ec3f5f923dbd6ff43022246a
parent0160ccef08c1c93763953d47d613e6aa6d0acd30 (diff)
downloadmullvadvpn-659aa11f05ae2b278eef6ab0ef5bc537e756109a.tar.xz
mullvadvpn-659aa11f05ae2b278eef6ab0ef5bc537e756109a.zip
Update linter configs
-rw-r--r--gui/.eslintignore4
-rw-r--r--gui/.eslintrc.js120
-rw-r--r--gui/.prettierignore2
-rw-r--r--gui/.prettierrc.yml11
-rw-r--r--gui/eslint.config.mjs166
-rw-r--r--gui/prettier.config.mjs7
6 files changed, 173 insertions, 137 deletions
diff --git a/gui/.eslintignore b/gui/.eslintignore
deleted file mode 100644
index 07b7d976c2..0000000000
--- a/gui/.eslintignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.eslintrc.js
-gulpfile.js
-init.js
-tasks/*.js
diff --git a/gui/.eslintrc.js b/gui/.eslintrc.js
deleted file mode 100644
index 4e4b1e0abe..0000000000
--- a/gui/.eslintrc.js
+++ /dev/null
@@ -1,120 +0,0 @@
-const namingConvention = [
- {
- selector: 'default',
- format: ['camelCase'],
- },
- {
- selector: 'variable',
- modifiers: ['const'],
- format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
- leadingUnderscore: 'allow',
- },
- {
- selector: 'variableLike',
- format: ['camelCase'],
- leadingUnderscore: 'allow',
- },
- {
- selector: 'import',
- format: ['camelCase', 'PascalCase', 'snake_case'],
- },
- {
- selector: 'parameter',
- format: ['camelCase', 'PascalCase'],
- leadingUnderscore: 'allow',
- },
- {
- selector: 'function',
- format: ['camelCase', 'PascalCase'],
- },
- {
- selector: 'memberLike',
- format: ['camelCase'],
- },
- {
- selector: 'typeProperty',
- format: ['camelCase'],
- filter: {
- regex: "^(data-testid|aria-labelledby|aria-describedby)$",
- match: false,
- },
- },
- {
- selector: 'typeLike',
- format: ['PascalCase'],
- },
- {
- selector: 'property',
- format: null,
- },
-];
-
-const memberOrdering = {
- default: [
- 'public-field',
- 'protected-field',
- 'private-field',
-
- 'public-constructor',
- 'protected-constructor',
- 'private-constructor',
-
- 'public-method',
- 'protected-method',
- 'private-method',
- ],
-};
-
-module.exports = {
- env: {
- es6: true,
- node: true,
- },
- parserOptions: {
- parser: '@typescript-eslint/parser',
- project: './tsconfig.json',
- tsconfigRootDir: __dirname,
- ecmaVersion: '2018',
- sourceType: 'module',
- ecmaFeatures: {
- jsx: true,
- },
- },
- ignorePatterns: ['test/*', 'scripts/*'],
- plugins: ['prettier', 'simple-import-sort'],
- extends: [
- 'eslint:recommended',
- 'plugin:@typescript-eslint/recommended',
- 'plugin:react/recommended',
- 'plugin:react/jsx-runtime',
- ],
- settings: {
- react: {
- createClass: 'createReactClass',
- pragma: 'React',
- version: 'detect',
- },
- },
- rules: {
- quotes: ['error', 'single', { avoidEscape: true }],
- 'prettier/prettier': 'error',
- '@typescript-eslint/no-unused-vars': [
- 'error',
- { argsIgnorePattern: '^_', ignoreRestSiblings: true },
- ],
- '@typescript-eslint/require-await': 'error',
- '@typescript-eslint/no-floating-promises': 'error',
- '@typescript-eslint/no-unused-expressions': 'error',
- '@typescript-eslint/member-ordering': ['error', memberOrdering],
- 'no-return-await': 'error',
- 'react/jsx-no-bind': 'error',
- '@typescript-eslint/naming-convention': ['error', ...namingConvention],
- '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': false }],
- 'simple-import-sort/imports': 'error',
-
- '@typescript-eslint/no-use-before-define': 'off',
- '@typescript-eslint/explicit-module-boundary-types': 'off',
- '@typescript-eslint/no-non-null-assertion': 'off',
- 'react/prop-types': 'off',
- },
-};
diff --git a/gui/.prettierignore b/gui/.prettierignore
deleted file mode 100644
index b38db2f296..0000000000
--- a/gui/.prettierignore
+++ /dev/null
@@ -1,2 +0,0 @@
-node_modules/
-build/
diff --git a/gui/.prettierrc.yml b/gui/.prettierrc.yml
deleted file mode 100644
index 7c4217913d..0000000000
--- a/gui/.prettierrc.yml
+++ /dev/null
@@ -1,11 +0,0 @@
----
-# .prettierrc.yml
-# see: https://prettier.io/docs/en/options.html
-printWidth: 100
-semi: true
-singleQuote: true
-trailingComma: all
-bracketSpacing: true
-jsxBracketSameLine: true
-arrowParens: always
-proseWrap: always
diff --git a/gui/eslint.config.mjs b/gui/eslint.config.mjs
new file mode 100644
index 0000000000..5c2b5d848c
--- /dev/null
+++ b/gui/eslint.config.mjs
@@ -0,0 +1,166 @@
+import eslint from '@eslint/js';
+import prettier from 'eslint-plugin-prettier/recommended';
+import react from 'eslint-plugin-react';
+import simpleImportSort from 'eslint-plugin-simple-import-sort';
+import globals from 'globals';
+import tseslint from 'typescript-eslint';
+
+const namingConvention = [
+ {
+ selector: 'default',
+ format: ['camelCase'],
+ },
+ {
+ selector: 'variable',
+ modifiers: ['const'],
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
+ leadingUnderscore: 'allow',
+ },
+ {
+ selector: 'variableLike',
+ format: ['camelCase'],
+ leadingUnderscore: 'allow',
+ },
+ {
+ selector: 'import',
+ format: ['camelCase', 'PascalCase', 'snake_case'],
+ },
+ {
+ selector: 'parameter',
+ format: ['camelCase', 'PascalCase'],
+ leadingUnderscore: 'allow',
+ },
+ {
+ selector: 'function',
+ format: ['camelCase', 'PascalCase'],
+ },
+ {
+ selector: 'memberLike',
+ format: ['camelCase'],
+ },
+ {
+ selector: 'typeProperty',
+ format: ['camelCase'],
+ filter: {
+ regex: '^(data-testid|aria-labelledby|aria-describedby)$',
+ match: false,
+ },
+ },
+ {
+ selector: 'typeLike',
+ format: ['PascalCase'],
+ },
+ {
+ selector: 'property',
+ format: null,
+ },
+];
+
+const memberOrdering = {
+ default: [
+ 'public-field',
+ 'protected-field',
+ 'private-field',
+
+ 'public-constructor',
+ 'protected-constructor',
+ 'private-constructor',
+
+ 'public-method',
+ 'protected-method',
+ 'private-method',
+ ],
+};
+
+export default tseslint.config(
+ eslint.configs.recommended,
+ ...tseslint.configs.recommended,
+ react.configs.flat.recommended,
+ prettier,
+ { ignores: ['build/*'] },
+ {
+ settings: {
+ react: {
+ createClass: 'createReactClass',
+ pragma: 'React',
+ version: 'detect',
+ },
+ },
+ },
+ {
+ files: ['**/*'],
+ ignores: ['src/renderer/**/*'],
+ languageOptions: {
+ globals: globals.node,
+ },
+ },
+ {
+ files: ['src/renderer/**/*'],
+ languageOptions: {
+ globals: globals.browser,
+ },
+ },
+ {
+ files: ['test/**/*'],
+ languageOptions: {
+ globals: globals.mocha,
+ },
+ },
+ {
+ files: ['src/**/*.{js,mjs,ts,tsx}'],
+ languageOptions: {
+ parserOptions: {
+ parser: '@typescript-eslint/parser',
+ project: './tsconfig.json',
+ ecmaVersion: '2018',
+ sourceType: 'module',
+ ecmaFeatures: {
+ jsx: true,
+ },
+ },
+ },
+ rules: {
+ '@typescript-eslint/require-await': 'error',
+ '@typescript-eslint/no-floating-promises': 'error',
+ },
+ },
+ {
+ files: ['**/*.{js,mjs,ts,tsx}'],
+ plugins: {
+ 'simple-import-sort': simpleImportSort,
+ },
+ rules: {
+ quotes: ['error', 'single', { avoidEscape: true }],
+ // 'prettier/prettier': 'error',
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ { argsIgnorePattern: '^_', ignoreRestSiblings: true },
+ ],
+ '@typescript-eslint/no-unused-expressions': 'error',
+ '@typescript-eslint/member-ordering': ['error', memberOrdering],
+ 'no-return-await': 'error',
+ 'react/jsx-no-bind': 'error',
+ '@typescript-eslint/naming-convention': ['error', ...namingConvention],
+ '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': false }],
+ 'simple-import-sort/imports': 'error',
+
+ '@typescript-eslint/no-use-before-define': 'off',
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ 'react/prop-types': 'off',
+ 'react/react-in-jsx-scope': 'off',
+ },
+ },
+ {
+ files: ['test/**/*.spec.ts'],
+ rules: {
+ '@typescript-eslint/no-unused-expressions': 'off',
+ },
+ },
+ {
+ files: ['tasks/*', 'scripts/*', 'gulpfile.js', 'init.js'],
+ rules: {
+ '@typescript-eslint/no-require-imports': 'off',
+ },
+ },
+);
diff --git a/gui/prettier.config.mjs b/gui/prettier.config.mjs
new file mode 100644
index 0000000000..150678b825
--- /dev/null
+++ b/gui/prettier.config.mjs
@@ -0,0 +1,7 @@
+// see: https://prettier.io/docs/en/options.html
+export default {
+ printWidth: 100,
+ singleQuote: true,
+ bracketSameLine: true,
+ proseWrap: 'always',
+};