Skip to content

Commit

Permalink
Add autofixable lint to sort imports (#39)
Browse files Browse the repository at this point in the history
* Add autofixable lint to sort imports

* fixup: more svelte
  • Loading branch information
mcous authored Apr 9, 2024
1 parent a6efc6a commit 5b60923
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest-dom": "^5.2.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-sonarjs": "^0.25.1",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-tailwindcss": "^3.15.1",
Expand Down
24 changes: 23 additions & 1 deletion packages/eslint-config/base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'simple-import-sort'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
Expand Down Expand Up @@ -171,6 +171,28 @@ module.exports = {
],
'@typescript-eslint/promise-function-async': 'error',

// Import sorting
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports
['^\\u0000'],
// Node.js builtins
['^node:'],
// Third-party packages
['^vitest', '^svelte', '^@sveltejs', '^@?\\w'],
// First-party packages
['^@viamrobotics'],
// Anything not matched in another group, like internal $alias imports
['^'],
// Relative imports
['^\\.'],
],
},
],
'simple-import-sort/exports': 'error',

// Extra SonarJS rules
'sonarjs/cognitive-complexity': ['error', 20],

Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "0.4.1",
"version": "0.5.0",
"description": "Common ESLint configuration for Viam projects.",
"files": [
"**/*",
Expand Down Expand Up @@ -46,6 +46,7 @@
"eslint": ">=8 <9",
"eslint-config-prettier": ">=9 <10",
"eslint-plugin-jest-dom": ">=5 <6",
"eslint-plugin-simple-import-sort": ">=12 <13",
"eslint-plugin-sonarjs": ">=0.19 <0.26",
"eslint-plugin-svelte": ">=2 <3",
"eslint-plugin-tailwindcss": ">=3 <4",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/peers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable unicorn/no-array-for-each */
import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
import fs from 'node:fs';
import { describe, it, expect } from 'vitest';

import { describe, expect, it } from 'vitest';
import semver from 'semver';

interface PackageJSON {
Expand Down

0 comments on commit 5b60923

Please sign in to comment.