Skip to content

Require sorted imports #1725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Require sorted imports
  • Loading branch information
martijnversluis committed Jun 10, 2025
commit 0450ffe6530f6645b644a842cbc0c98e180d3287
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export default tseslint.config(
'operator-linebreak': ['error', 'after'],
'quotes': ['error', 'single'],
'quote-props': ['error', 'consistent'],
'sort-imports': [
'error',
{
allowSeparatedGroups: true,
memberSyntaxSortOrder: [
'none',
'all',
'single',
'multiple',
],
}],

'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
2 changes: 1 addition & 1 deletion script/build_scales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
NUMERAL,
NUMERIC,
SHARP,
SYMBOL,
SOLFEGE,
SYMBOL,
} from '../src/constants';

interface BuildOptions {
Expand Down
3 changes: 2 additions & 1 deletion script/debug_parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import process from 'process';
import PeggyOnline from './helpers/peggy_online';

import ParserBuilder from './helpers/parser_builder';
import PeggyOnline from './helpers/peggy_online';

const parserSource = new ParserBuilder(process.argv[2]).build();

Expand Down
1 change: 1 addition & 0 deletions script/helpers/parser_builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';

import esbuild from 'esbuild';

class ParserBuilder {
Expand Down
2 changes: 1 addition & 1 deletion script/helpers/peggy_online.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer, { Browser, Page } from 'puppeteer';
import process from 'process';
import puppeteer, { Browser, Page } from 'puppeteer';

class PeggyOnline {
parserSource: string;
Expand Down
7 changes: 4 additions & 3 deletions src/chord.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { parse } from './parser/chord/peg_parser';
import ChordParsingError from './chord_parsing_error';
import Key from './key';
import { parse } from './parser/chord/peg_parser';
import { isMinor, normalizeChordSuffix } from './utilities';
import ChordParsingError from './chord_parsing_error';

import {
ChordType,
Modifier,
NUMERAL,
NUMERIC,
SYMBOL,
SOLFEGE,
SYMBOL,
} from './constants';

interface ChordProperties {
Expand Down
4 changes: 2 additions & 2 deletions src/chord_sheet/ast_type.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ChordLyricsPair from './chord_lyrics_pair';
import Comment from './comment';
import Tag from './tag';
import Ternary from './chord_pro/ternary';
import Evaluatable from './chord_pro/evaluatable';
import Literal from './chord_pro/literal';
import SoftLineBreak from './soft_line_break';
import Tag from './tag';
import Ternary from './chord_pro/ternary';

type AstType = ChordLyricsPair | Comment | Tag | Ternary | Evaluatable | Literal | SoftLineBreak;

Expand Down
6 changes: 3 additions & 3 deletions src/chord_sheet/chord_pro/ternary.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import EvaluationError from './evaluation_error';
import { isEmptyString } from '../../utilities';
import Composite from './composite';
import TraceInfo from '../trace_info';
import Evaluatable from './evaluatable';
import EvaluationError from './evaluation_error';
import Metadata from '../metadata';
import TraceInfo from '../trace_info';
import { isEmptyString } from '../../utilities';

export type TernaryProperties = TraceInfo & {
variable?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion src/chord_sheet/item.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ChordLyricsPair from './chord_lyrics_pair';
import Comment from './comment';
import Literal from './chord_pro/literal';
import Tag from './tag';
import Ternary from './chord_pro/ternary';
import Literal from './chord_pro/literal';

type Item = ChordLyricsPair | Comment | Tag | Ternary | Literal;

Expand Down
4 changes: 2 additions & 2 deletions src/chord_sheet/line.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ChordLyricsPair from './chord_lyrics_pair';
import Tag from './tag';
import Comment from './comment';
import Item from './item';
import Font from './font';
import Item from './item';
import Tag from './tag';
import { ContentType, PartTypes } from '../serialized_types';

import {
Expand Down
3 changes: 2 additions & 1 deletion src/chord_sheet/line_expander.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Item from './item';
import Line from './line';
import Song from './song';
import Item from './item';
import Tag from './tag';

import { CHORUS } from '../constants';
import { END_OF_CHORUS, START_OF_CHORUS } from './tags';

Expand Down
5 changes: 2 additions & 3 deletions src/chord_sheet/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Key from '../key';
import MetadataAccessors from './metadata_accessors';

import { isReadonlyTag } from './tag';
import Key from '../key';
import { _KEY, CAPO, KEY } from './tags';
import { CAPO, KEY, _KEY } from './tags';

function appendValue(array: string[], value: string): void {
if (!array.includes(value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/chord_sheet/paragraph.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { INDETERMINATE } from '../constants';
import Item from './item';
import Line from './line';
import Literal from './chord_pro/literal';
import Tag from './tag';
import Item from './item';

function getCommonValue(values: string[], fallback: string | null): string | null {
const uniqueValues = [...new Set(values)];
Expand Down
27 changes: 14 additions & 13 deletions src/chord_sheet/song.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import Line from './line';
import Paragraph from './paragraph';
import Key from '../key';
import Chord from '../chord';
import ChordDefinition from '../chord_definition/chord_definition';
import ChordDefinitionSet from '../chord_definition/chord_definition_set';
import ChordLyricsPair from './chord_lyrics_pair';
import FormattingContext from '../formatter/formatting_context';
import Item from './item';
import Key from '../key';
import Line from './line';
import LineExpander from './line_expander';
import Metadata from './metadata';
import ParserWarning from '../parser/parser_warning';
import MetadataAccessors from './metadata_accessors';
import Item from './item';
import { Modifier } from '../constants';
import Paragraph from './paragraph';
import ParserWarning from '../parser/parser_warning';
import SongBuilder from '../song_builder';
import ChordDefinition from '../chord_definition/chord_definition';
import Chord from '../chord';
import FormattingContext from '../formatter/formatting_context';
import { testSelector } from '../helpers';
import ChordDefinitionSet from '../chord_definition/chord_definition_set';
import Tag from './tag';

import { Modifier } from '../constants';
import { filterObject } from '../utilities';
import { testSelector } from '../helpers';
import { CAPO, KEY } from './tags';
import LineExpander from './line_expander';
import SongMapper, { MapItemsCallback } from './song_mapper';
import { filterObject } from '../utilities';

/**
* Represents a song in a chord sheet. Currently a chord sheet can only have one song.
Expand Down
2 changes: 1 addition & 1 deletion src/chord_sheet/song_mapper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Item from './item';
import Line from './line';
import Song from './song';
import SongBuilder from '../song_builder';
import Line from './line';

export type MapItemsCallback = (_item: Item) => Item | Item[] | null;

Expand Down
13 changes: 7 additions & 6 deletions src/chord_sheet/tag.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import AstComponent from './ast_component';
import TraceInfo from './trace_info';
import ChordDefinition from '../chord_definition/chord_definition';
import TagInterpreter from './tag_interpreter';
import TraceInfo from './trace_info';

import {
_KEY,
ALBUM,
ARRANGER,
ARTIST,
CAPO,
CHORD_STYLE,
CHORDCOLOUR,
CHORDFONT,
CHORDSIZE,
CHORD_STYLE,
CHORUS,
COMMENT,
COMPOSER,
Expand All @@ -23,8 +24,8 @@ import {
END_OF_TAB,
END_OF_VERSE,
KEY,
LYRICIST, NEW_KEY,
SORTTITLE,
LYRICIST,
NEW_KEY, SORTTITLE,
START_OF_ABC,
START_OF_BRIDGE,
START_OF_CHORUS,
Expand All @@ -41,9 +42,9 @@ import {
TIME,
TITLE,
YEAR,
_KEY,
} from './tags';

import TagInterpreter from './tag_interpreter';
import { END_TAG, START_TAG } from '../constants';

const CHORDFONT_SHORT = 'cf';
Expand Down
23 changes: 12 additions & 11 deletions src/chord_sheet_serializer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import AstType from './chord_sheet/ast_type';
import Chord from './chord';
import ChordDefinition from './chord_definition/chord_definition';
import ChordLyricsPair from './chord_sheet/chord_lyrics_pair';
import Comment from './chord_sheet/comment';
import Evaluatable from './chord_sheet/chord_pro/evaluatable';
import Item from './chord_sheet/item';
import Line from './chord_sheet/line';
import Literal from './chord_sheet/chord_pro/literal';
import SoftLineBreak from './chord_sheet/soft_line_break';
import Song from './chord_sheet/song';
import ChordLyricsPair from './chord_sheet/chord_lyrics_pair';
import SongBuilder from './song_builder';
import Tag from './chord_sheet/tag';
import Comment from './chord_sheet/comment';
import Ternary from './chord_sheet/chord_pro/ternary';
import Chord from './chord';
import Line from './chord_sheet/line';
import AstType from './chord_sheet/ast_type';
import Item from './chord_sheet/item';
import Evaluatable from './chord_sheet/chord_pro/evaluatable';

import { warn } from './utilities';

import {
SerializedChordDefinition,
Expand All @@ -20,10 +25,6 @@ import {
SerializedSong,
SerializedTag, SerializedTernary,
} from './serialized_types';
import SoftLineBreak from './chord_sheet/soft_line_break';
import { warn } from './utilities';
import ChordDefinition from './chord_definition/chord_definition';
import SongBuilder from './song_builder';

const CHORD_LYRICS_PAIR = 'chordLyricsPair';
const CHORD_SHEET = 'chordSheet';
Expand Down
18 changes: 9 additions & 9 deletions src/formatter/chord_pro_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Formatter from './formatter';
import Tag from '../chord_sheet/tag';
import Chord from '../chord';
import ChordLyricsPair from '../chord_sheet/chord_lyrics_pair';
import Ternary from '../chord_sheet/chord_pro/ternary';
import Literal from '../chord_sheet/chord_pro/literal';
import Song from '../chord_sheet/song';
import Comment from '../chord_sheet/comment';
import Evaluatable from '../chord_sheet/chord_pro/evaluatable';
import Formatter from './formatter';
import Item from '../chord_sheet/item';
import Line from '../chord_sheet/line';
import Literal from '../chord_sheet/chord_pro/literal';
import Metadata from '../chord_sheet/metadata';
import Item from '../chord_sheet/item';
import Evaluatable from '../chord_sheet/chord_pro/evaluatable';
import Comment from '../chord_sheet/comment';
import SoftLineBreak from '../chord_sheet/soft_line_break';
import Chord from '../chord';
import Song from '../chord_sheet/song';
import Tag from '../chord_sheet/tag';
import Ternary from '../chord_sheet/chord_pro/ternary';

/**
* Formats a song into a ChordPro chord sheet
Expand Down
2 changes: 1 addition & 1 deletion src/formatter/chord_renderer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Chord from '../chord';
import Key from '../key';
import { NullableChordStyle } from '../constants';
import { transposeDistance } from '../helpers';
import { callChain } from '../utilities';
import { transposeDistance } from '../helpers';

interface ConstructorOptions {
capo: number;
Expand Down
17 changes: 9 additions & 8 deletions src/formatter/chords_over_words_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Formatter from './formatter';
import ChordLyricsPair from '../chord_sheet/chord_lyrics_pair';
import Formatter from './formatter';
import Item from '../chord_sheet/item';
import Line from '../chord_sheet/line';
import Metadata from '../chord_sheet/metadata';
import Paragraph from '../chord_sheet/paragraph';
import Song from '../chord_sheet/song';
import Tag from '../chord_sheet/tag';

import { Ternary } from '../index';
import { renderChord } from '../helpers';
import { hasTextContents, renderSection } from '../template_helpers';
import Song from '../chord_sheet/song';
import { hasRemarkContents, isEmptyString, padLeft } from '../utilities';
import Paragraph from '../chord_sheet/paragraph';
import Metadata from '../chord_sheet/metadata';
import Line from '../chord_sheet/line';
import Item from '../chord_sheet/item';
import { Ternary } from '../index';
import { hasTextContents, renderSection } from '../template_helpers';

/**
* Formats a song into a plain text chord sheet
Expand Down
1 change: 1 addition & 0 deletions src/formatter/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Key from '../key';

import { ContentType } from '../serialized_types';

export type Delegate = (_string: string) => string;
Expand Down
3 changes: 2 additions & 1 deletion src/formatter/html_div_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HtmlFormatter, { CSS, HtmlTemplateCssClasses, Template } from './html_formatter';
import template from './templates/html_div_formatter';

import HtmlFormatter, { CSS, HtmlTemplateCssClasses, Template } from './html_formatter';

function defaultCss(cssClasses: HtmlTemplateCssClasses): CSS {
const {
chord,
Expand Down
5 changes: 3 additions & 2 deletions src/formatter/html_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Formatter from './formatter';
import Configuration, { ConfigurationProperties } from './configuration';
import Paragraph from '../chord_sheet/paragraph';
import Song from '../chord_sheet/song';

import { scopeCss } from '../utilities';
import Paragraph from '../chord_sheet/paragraph';
import Configuration, { ConfigurationProperties } from './configuration';

export interface HtmlTemplateCssClasses {
annotation: string,
Expand Down
3 changes: 2 additions & 1 deletion src/formatter/html_table_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HtmlFormatter, { Template, CSS, HtmlTemplateCssClasses } from './html_formatter';
import template from './templates/html_table_formatter';

import HtmlFormatter, { CSS, HtmlTemplateCssClasses, Template } from './html_formatter';

/* eslint-disable-next-line max-lines-per-function */
function defaultCss(cssClasses: HtmlTemplateCssClasses): CSS {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/formatter/templates/html_div_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HtmlTemplateArgs } from '../html_formatter';
import { isPresent } from '../../utilities';
import { renderChord } from '../../helpers';

import {
Expand All @@ -15,7 +16,6 @@ import {
stripHTML,
when,
} from '../../template_helpers';
import { isPresent } from '../../utilities';

export default (
{
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/templates/html_table_formatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { hasChordContents, isEvaluatable, isPresent } from '../../utilities';
import { renderChord } from '../../helpers';
import { HtmlTemplateArgs } from '../html_formatter';
import { renderChord } from '../../helpers';
import { hasChordContents, isEvaluatable, isPresent } from '../../utilities';

import {
each,
Expand Down
Loading