Skip to content
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

Chore (linting): Enforce imports order & validation #1293

Merged
merged 1 commit into from
Sep 4, 2023
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
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"root": true,
"extends": ["xo", "prettier", "plugin:n/recommended-module"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "unicorn", "prettier"],
"plugins": ["@typescript-eslint", "unicorn", "prettier", "import"],
"env": {
"node": true,
"es2022": true
Expand Down Expand Up @@ -31,6 +31,8 @@
"null": "ignore"
}
],
"import/no-duplicates": "error",
"import/order": "error",
"prettier/prettier": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/prefer-module": "error",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-xo": "^0.43.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.0.2",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-unicorn": "^48.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/core.test.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
import { render } from '@inquirer/testing';
import stripAnsi from 'strip-ansi';
import ansiEscapes from 'ansi-escapes';
import {
createPrompt,
useEffect,
Expand All @@ -12,8 +14,6 @@ import {
Separator,
type KeypressEvent,
} from './src/index.mjs';
import stripAnsi from 'strip-ansi';
import ansiEscapes from 'ansi-escapes';

describe('createPrompt()', () => {
it('handle async function message', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/examples/bottom-bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BottomBar from '../lib/ui/bottom-bar.js';
import { spawn } from 'node:child_process';
import BottomBar from '../lib/ui/bottom-bar.js';

const loader = ['/ Installing', '| Installing', '\\ Installing', '- Installing'];
let i = 4;
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/examples/rx-observable-array.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inquirer from '../lib/inquirer.js';
import { from } from 'rxjs';
import inquirer from '../lib/inquirer.js';

const questions = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/examples/rx-observable-create.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inquirer from '../lib/inquirer.js';
import { Observable } from 'rxjs';
import inquirer from '../lib/inquirer.js';

const observe = Observable.create((obs) => {
obs.next({
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/examples/terminal-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* For screenshots of the expected behavior, see https://github.com/SBoudrias/Inquirer.js/pull/1106
*/

import inquirer from '../lib/inquirer.js';
import terminalLink from 'terminal-link';
import inquirer from '../lib/inquirer.js';

inquirer
.prompt([
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import chalk from 'chalk';
import cliCursor from 'cli-cursor';
import figures from 'figures';
import { map, takeUntil } from 'rxjs';
import Base from './base.js';
import observe from '../utils/events.js';
import Paginator from '../utils/paginator.js';
import incrementListIndex from '../utils/incrementListIndex.js';
import Base from './base.js';

export default class CheckboxPrompt extends Base {
constructor(questions, rl, answers) {
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import chalk from 'chalk';
import { take, takeUntil } from 'rxjs';
import Base from './base.js';
import observe from '../utils/events.js';
import Base from './base.js';

export default class ConfirmPrompt extends Base {
constructor(questions, rl, answers) {
Expand Down
4 changes: 2 additions & 2 deletions packages/inquirer/lib/prompts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import chalk from 'chalk';
import { editAsync } from 'external-editor';
import Base from './base.js';
import observe from '../utils/events.js';
import { Subject } from 'rxjs';
import observe from '../utils/events.js';
import Base from './base.js';

export default class EditorPrompt extends Base {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import chalk from 'chalk';
import { map, takeUntil } from 'rxjs';
import Base from './base.js';
import Separator from '../objects/separator.js';
import observe from '../utils/events.js';
import Paginator from '../utils/paginator.js';
import Base from './base.js';

export default class ExpandPrompt extends Base {
constructor(questions, rl, answers) {
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import chalk from 'chalk';
import { map, takeUntil } from 'rxjs';
import Base from './base.js';
import observe from '../utils/events.js';
import Base from './base.js';

export default class InputPrompt extends Base {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import figures from 'figures';
import cliCursor from 'cli-cursor';
import runAsync from 'run-async';
import { flatMap, map, take, takeUntil } from 'rxjs';
import Base from './base.js';
import observe from '../utils/events.js';
import Paginator from '../utils/paginator.js';
import incrementListIndex from '../utils/incrementListIndex.js';
import Base from './base.js';

export default class ListPrompt extends Base {
constructor(questions, rl, answers) {
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import chalk from 'chalk';
import { map, takeUntil } from 'rxjs';
import Base from './base.js';
import observe from '../utils/events.js';
import Base from './base.js';

function mask(input, maskChar) {
input = String(input);
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/rawlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import chalk from 'chalk';
import { map, takeUntil } from 'rxjs';
import Base from './base.js';
import Separator from '../objects/separator.js';
import observe from '../utils/events.js';
import Paginator from '../utils/paginator.js';
import incrementListIndex from '../utils/incrementListIndex.js';
import Base from './base.js';

export default class RawListPrompt extends Base {
constructor(questions, rl, answers) {
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/ui/baseUI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MuteStream from 'mute-stream';
import readline from 'node:readline';
import MuteStream from 'mute-stream';

/**
* Base interface class other can inherits from
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/ui/bottom-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/

import through from '@ljharb/through';
import Base from './baseUI.js';
import * as rlUtils from '../utils/readline.js';
import Base from './baseUI.js';

export default class BottomBar extends Base {
constructor(opt = {}) {
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/lib/ui/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const _ = {
set,
get,
};
import { defer, empty, from, of } from 'rxjs';
import { concatMap, filter, publish, reduce } from 'rxjs';
import { defer, empty, from, of, concatMap, filter, publish, reduce } from 'rxjs';
import runAsync from 'run-async';
import * as utils from '../utils/utils.js';
import Base from './baseUI.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/lib/utils/events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fromEvent } from 'rxjs';
import { filter, map, share, takeUntil } from 'rxjs';
import { fromEvent, filter, map, share, takeUntil } from 'rxjs';

function normalizeKeypressEvents(value, key) {
return { value, key: key || {} };
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/utils/screen-manager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as util from './readline.js';
import cliWidth from 'cli-width';
import wrapAnsi from 'wrap-ansi';
import stripAnsi from 'strip-ansi';
import stringWidth from 'string-width';
import ora from 'ora';
import * as util from './readline.js';

function height(content) {
return content.split('\n').length;
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/test/helpers/readline.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import { vi } from 'vitest';
import util from 'node:util';
import { vi } from 'vitest';

const stub = {};

Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Test Prompt public APIs
*/

import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import fixtures from '../helpers/fixtures.js';
import ReadlineStub from '../helpers/readline.js';
import inquirer from '../../lib/inquirer.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/objects/choice.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it } from 'vitest';
import { expect } from 'vitest';
import { describe, it, expect } from 'vitest';

import Choice from '../../../lib/objects/choice.js';
import Separator from '../../../lib/objects/separator.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/objects/choices.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it } from 'vitest';
import { expect } from 'vitest';
import { describe, it, expect } from 'vitest';

import inquirer from '../../../lib/inquirer.js';
import Choices from '../../../lib/objects/choices.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/objects/separator.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it } from 'vitest';
import { expect } from 'vitest';
import { describe, it, expect } from 'vitest';
import stripAnsi from 'strip-ansi';

import Separator from '../../../lib/objects/separator.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/base.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';

import Base from '../../../lib/prompts/base.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/confirm.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/editor.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { beforeEach, afterEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { createRequire } from 'node:module';
import { beforeEach, afterEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/expand.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

Expand Down
4 changes: 1 addition & 3 deletions packages/inquirer/test/specs/prompts/input.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { describe, it, beforeEach } from 'vitest';
import { expect } from 'vitest';
import { describe, it, beforeEach, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

import Input from '../../../lib/prompts/input.js';

describe('`input` prompt', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/number.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/prompts/password.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import stripAnsi from 'strip-ansi';
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

Expand Down
4 changes: 1 addition & 3 deletions packages/inquirer/test/specs/prompts/rawlist.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import ReadlineStub from '../../helpers/readline.js';
import fixtures from '../../helpers/fixtures.js';

import Rawlist from '../../../lib/prompts/rawlist.js';

describe('`rawlist` prompt', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/test/specs/utils/paginator.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { beforeEach, describe, it } from 'vitest';
import { expect } from 'vitest';
import { beforeEach, describe, it, expect } from 'vitest';
import Paginator from '../../../lib/utils/paginator.js';

const output = `\
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/src/index.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stream } from 'node:stream';
import MuteStream from 'mute-stream';
import stripAnsi from 'strip-ansi';
import ansiEscapes from 'ansi-escapes';
import { Stream } from 'node:stream';
import type { Prompt } from '@inquirer/type';

const ignoredAnsi = new Set([ansiEscapes.cursorHide, ansiEscapes.cursorShow]);
Expand Down
Loading