Skip to content

Commit 8cfbf80

Browse files
authored
Add ESLint formatter for sorting imports (#1468)
1 parent 7c166f7 commit 8cfbf80

File tree

310 files changed

+1181
-700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+1181
-700
lines changed

.eslintrc.cjs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
'plugin:@typescript-eslint/recommended',
77
'prettier',
88
],
9-
plugins: ['svelte3', '@typescript-eslint', 'vitest'],
9+
plugins: ['svelte3', '@typescript-eslint', 'vitest', 'import'],
1010
ignorePatterns: ['*.cjs', 'prism.cjs', '/server'],
1111
overrides: [
1212
{
@@ -54,7 +54,7 @@ module.exports = {
5454
},
5555
rules: {
5656
'@typescript-eslint/no-unused-vars': [
57-
1,
57+
'error',
5858
{
5959
argsIgnorePattern: '^_',
6060
varsIgnorePattern: '^_',
@@ -79,5 +79,43 @@ module.exports = {
7979
],
8080
},
8181
],
82+
'sort-imports': [
83+
'error',
84+
{ ignoreCase: true, ignoreDeclarationSort: true },
85+
],
86+
'import/order': [
87+
'error',
88+
{
89+
groups: [
90+
'builtin',
91+
'external',
92+
'internal',
93+
['parent', 'sibling', 'index'],
94+
],
95+
pathGroups: [
96+
{
97+
pattern: 'svelte/**',
98+
group: 'external',
99+
position: 'before',
100+
},
101+
{ pattern: '$app/**', group: 'external', position: 'after' },
102+
{ pattern: './$types', group: 'external', position: 'after' },
103+
{ pattern: '$lib/**', group: 'internal' },
104+
{
105+
pattern: '$components/**/*.svelte',
106+
group: 'internal',
107+
position: 'after',
108+
},
109+
{ pattern: './**/*.svelte', group: 'index', position: 'after' },
110+
],
111+
pathGroupsExcludedImportTypes: ['svelte'],
112+
'newlines-between': 'always',
113+
alphabetize: {
114+
order: 'asc',
115+
caseInsensitive: false,
116+
orderImportKind: 'asc',
117+
},
118+
},
119+
],
82120
},
83121
};

cypress/integration/event-history.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import { formatDistanceToNow } from 'date-fns';
44
import * as dateTz from 'date-fns-tz';
55

6-
import workflowCompletedFixture from '../fixtures/workflow-completed.json';
76
import eventsFixtureDescending from '../fixtures/event-history-completed-reverse.json';
87
import eventsFixtureAscending from '../fixtures/event-history-completed.json';
8+
import workflowCompletedFixture from '../fixtures/workflow-completed.json';
99

1010
const [firstEventInDescendingOrder] = eventsFixtureDescending.history.events;
1111

cypress/integration/task-queues.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import * as dateTz from 'date-fns-tz';
44

5-
import wtq from '../fixtures/worker-task-queues.json';
65
import atq from '../fixtures/activity-task-queues.json';
6+
import wtq from '../fixtures/worker-task-queues.json';
77

88
describe('Task Queues Page', () => {
99
beforeEach(() => {

cypress/integration/workers.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import * as dateTz from 'date-fns-tz';
44

5-
import workflowCompletedFixture from '../fixtures/workflow-completed.json';
6-
import wtq from '../fixtures/worker-task-queues.json';
75
import atq from '../fixtures/activity-task-queues.json';
6+
import wtq from '../fixtures/worker-task-queues.json';
7+
import workflowCompletedFixture from '../fixtures/workflow-completed.json';
88

99
const { workflowId, runId } =
1010
workflowCompletedFixture.workflowExecutionInfo.execution;

cypress/integration/workflow-input-and-results.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/// <reference types="cypress" />
22

3-
import workflowsFixture from '../fixtures/workflows.json';
4-
import eventsCompletedFixture from '../fixtures/event-history-completed.json';
5-
import eventsCompletedNullFixture from '../fixtures/event-history-completed-null.json';
6-
import eventsRunningFixture from '../fixtures/event-history-running.json';
7-
import eventsFailedFixture from '../fixtures/event-history-failed.json';
83
import eventsCanceledFixture from '../fixtures/event-history-canceled.json';
4+
import eventsCompletedNullFixture from '../fixtures/event-history-completed-null.json';
5+
import eventsCompletedFixture from '../fixtures/event-history-completed.json';
96
import eventsContinuedAsNewFixture from '../fixtures/event-history-continued-as-new.json';
7+
import eventsFailedFixture from '../fixtures/event-history-failed.json';
8+
import eventsRunningFixture from '../fixtures/event-history-running.json';
109
import eventsTimedOutFixture from '../fixtures/event-history-timed-out.json';
10+
import workflowsFixture from '../fixtures/workflows.json';
1111

1212
const workflow = workflowsFixture.executions[0];
1313
const { workflowId, runId } = workflow.execution;

histoire.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
2-
import { defaultColors, defineConfig } from 'histoire';
2+
33
import { HstSvelte as histoire } from '@histoire/plugin-svelte';
4+
import { defaultColors, defineConfig } from 'histoire';
45

56
export default defineConfig({
67
plugins: [histoire()],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"eslint": "^8.34.0",
144144
"eslint-config-prettier": "^8.6.0",
145145
"eslint-plugin-cypress": "^2.12.1",
146+
"eslint-plugin-import": "^2.27.5",
146147
"eslint-plugin-playwright": "^0.12.0",
147148
"eslint-plugin-svelte3": "^4.0.0",
148149
"eslint-plugin-vitest": "^0.0.34",

plugins/vite-plugin-i18n-locales.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Plugin } from 'vite';
2+
23
import { generateLocales } from '../utilities/generate-locales';
34

45
type PluginOptions = {

plugins/vite-plugin-temporal-server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { chalk } from 'zx';
21
import type { Plugin } from 'vite';
2+
import type { ViteDevServer } from 'vite';
3+
import { chalk } from 'zx';
4+
35
import {
4-
type TemporalServer,
56
createTemporalServer,
7+
type TemporalServer,
68
} from '../utilities/temporal-server';
7-
import type { ViteDevServer } from 'vite';
89

910
const { cyan, magenta } = chalk;
1011

plugins/vite-plugin-ui-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { Plugin } from 'vite';
2-
import { createUIServer, UIServer } from '../utilities/ui-server';
32
import type { ViteDevServer } from 'vite';
43

4+
import { createUIServer, UIServer } from '../utilities/ui-server';
5+
56
let uiServer: UIServer;
67

78
const shouldSkip = (server: ViteDevServer): boolean => {

0 commit comments

Comments
 (0)