Skip to content

Commit

Permalink
chore: tweak lint config to allow for eslint --fix to fix import or…
Browse files Browse the repository at this point in the history
…der (#1827)
  • Loading branch information
filmaj authored Jun 18, 2024
1 parent b1dad13 commit fc87d51
Show file tree
Hide file tree
Showing 74 changed files with 501 additions and 424 deletions.
17 changes: 17 additions & 0 deletions lint-configs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ module.exports = {
},
],

// Rules about import ordering/sorting
'import/order': ['error', {
'groups': [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index'],
'object',
'type'
],
'newlines-between': 'always',
'alphabetize': {
'order': 'asc',
'caseInsensitive': true
}
}],
'sort-imports': ['error', { 'ignoreDeclarationSort': true }],
// Allow cyclical imports. Turning this rule on is mainly a way to manage the performance concern for linting
// time. Our projects are not large enough to warrant this. Overrides AirBnB styles.
'import/no-cycle': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/slackapi/node-slack-sdk/issues"
},
"scripts": {
"lint": "eslint --ext .ts src",
"lint": "eslint --fix --ext .ts src",
"build": "npm run build:clean && tsc",
"build:clean": "shx rm -rf ./dist ./coverage",
"prepare": "npm run build",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/cli-process.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { assert } from 'chai';
import sinon from 'sinon';
import { shell } from './shell';

import { SlackCLIProcess } from './cli-process';
import { shell } from './shell';

describe('SlackCLIProcess class', () => {
const sandbox = sinon.createSandbox();
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/cli-process.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SpawnOptionsWithoutStdio } from 'node:child_process';
import { shell } from './shell';

import type { ShellProcess } from '../utils/types';
import type { SpawnOptionsWithoutStdio } from 'node:child_process';
/*
* some parameters used in the 'shell' calls that are CLI-specific and probably should not exist there:
* @param skipUpdate skip auto update notification
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-test/src/cli/commands/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ShellProcess } from '../../utils/types';
import { SlackCLIProcess, SlackCLIGlobalOptions, SlackCLICommandOptions } from '../cli-process';
import { SlackCLICommandOptions, SlackCLIGlobalOptions, SlackCLIProcess } from '../cli-process';
import commandError from '../command-error';

import type { ShellProcess } from '../../utils/types';

export default {
/**
* `slack login --no-prompt`
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/commands/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SpawnOptionsWithoutStdio } from 'node:child_process';
import { SlackCLIProcess, SlackCLICommandOptions, SlackCLIGlobalOptions } from '../cli-process';

import { SlackCLICommandOptions, SlackCLIGlobalOptions, SlackCLIProcess } from '../cli-process';
import commandError from '../command-error';

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-test/src/cli/commands/platform.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SlackTracerId } from '../../utils/constants';
import logger from '../../utils/logger';
import { SlackCLIProcess } from '../cli-process';
import commandError from '../command-error';
import { shell } from '../shell';

import type { ShellProcess } from '../../utils/types';
import commandError from '../command-error';
import { SlackTracerId } from '../../utils/constants';

// TODO: the options for these methods could be DRYed up

Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sinon from 'sinon';
import logger from '../utils/logger';

import { SlackCLI } from './index';
import logger from '../utils/logger';

describe('cli module', () => {
const sandbox = sinon.createSandbox();
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import logger from '../utils/logger';

import appCommands from './commands/app';
import authCommands from './commands/auth';
import collaboratorCommands from './commands/collaborator';
Expand All @@ -11,6 +11,7 @@ import functionCommands from './commands/function';
import manifestCommands from './commands/manifest';
import platformCommands from './commands/platform';
import triggerCommands from './commands/trigger';
import logger from '../utils/logger';

/**
* Set of functions to spawn and interact with Slack Platform CLI processes and commands
Expand Down
9 changes: 6 additions & 3 deletions packages/cli-test/src/cli/shell.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { assert } from 'chai';
import sinon from 'sinon';
import child from 'child_process';
import stream from 'stream';
import EventEmitter from 'events';
import stream from 'stream';

import { assert } from 'chai';
import sinon from 'sinon';

import { shell } from './shell';

import type { ShellProcess } from '../utils/types';

describe('shell module', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/cli-test/src/cli/shell.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import child from 'child_process';

import treekill from 'tree-kill';
import logger from '../utils/logger';

import { timeouts } from '../utils/constants';
import logger from '../utils/logger';

import type { ShellProcess } from '../utils/types';

export const shell = {
Expand Down
1 change: 1 addition & 0 deletions packages/cli-test/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import sinon from 'sinon';

import { SlackCLI, SlackTracerId } from '.';

describe('main module', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-test/src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createLogger, format, transports, Logger } from 'winston';
import { Logger, createLogger, format, transports } from 'winston';

// Configure CLI log level
// Winston logging levels, see: https://github.com/winstonjs/winston#logging
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"prepare": "npm run build",
"build": "npm run build:clean && tsc",
"build:clean": "shx rm -rf ./dist ./coverage",
"lint": "eslint --ext .ts src",
"lint": "eslint --fix --ext .ts src",
"mocha": "mocha --config .mocharc.json src/*.spec.js",
"test:unit": "npm run build && npm run mocha",
"test": "npm run lint && npm run coverage",
Expand Down
3 changes: 2 additions & 1 deletion packages/oauth/src/callback-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IncomingMessage, ServerResponse } from 'http';

import { assert } from 'chai';
import { describe, it } from 'mocha';
import sinon from 'sinon';
import { IncomingMessage, ServerResponse } from 'http';

import { CallbackOptions, escapeHtml } from './callback-options';
import { MissingStateError } from './errors';
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/callback-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IncomingMessage, ServerResponse } from 'http';

import { CodedError, ErrorCode } from './errors';
import { InstallURLOptions } from './install-url-options';
import { Installation, OrgInstallation } from './installation';
Expand Down
3 changes: 2 additions & 1 deletion packages/oauth/src/install-path-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IncomingMessage, ServerResponse } from 'http';

import { assert } from 'chai';
import { describe, it } from 'mocha';
import sinon from 'sinon';
import { IncomingMessage, ServerResponse } from 'http';

import { InstallPathOptions } from './install-path-options';

Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/install-path-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IncomingMessage, ServerResponse } from 'http';

import { InstallURLOptions } from './install-url-options';

/**
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/install-provider-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import { describe, it } from 'mocha';

import { InstallProviderOptions } from './install-provider-options';

describe('InstallProviderOptions', async () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/oauth/src/install-provider-options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Logger, LogLevel } from '@slack/logger';
import { LogLevel, Logger } from '@slack/logger';
import { WebClientOptions } from '@slack/web-api';
import { StateStore } from './state-stores';
import { InstallationStore } from './installation-stores';

import { InstallURLOptions } from './install-url-options';
import { InstallationStore } from './installation-stores';
import { StateStore } from './state-stores';

export interface InstallProviderOptions {

Expand Down
26 changes: 13 additions & 13 deletions packages/oauth/src/install-provider.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { IncomingMessage, ServerResponse } from 'http';
import { URLSearchParams, URL } from 'url';
import { URL, URLSearchParams } from 'url';

import { WebAPICallResult, WebClient, WebClientOptions } from '@slack/web-api';

import { AuthorizeResult } from './authorize-result';
import { CallbackOptions, defaultCallbackFailure, defaultCallbackSuccess } from './callback-options';
import defaultRenderHtmlForInstallPath from './default-render-html-for-install-path';
import {
InstallerInitializationError,
UnknownError,
MissingStateError,
InvalidStateError,
MissingCodeError,
GenerateInstallUrlError,
AuthorizationError,
CodedError,
ErrorCode,
GenerateInstallUrlError,
InstallerInitializationError,
InvalidStateError,
MissingCodeError,
MissingStateError,
UnknownError,
} from './errors';
import { InstallPathOptions } from './install-path-options';
import { InstallProviderOptions } from './install-provider-options';
import { InstallURLOptions } from './install-url-options';
import { Installation } from './installation';
import { InstallationQuery } from './installation-query';
import { InstallURLOptions } from './install-url-options';
import { InstallProviderOptions } from './install-provider-options';
import { Logger, LogLevel, getLogger } from './logger';
import { ClearStateStore, StateStore } from './state-stores';
import { InstallationStore, MemoryInstallationStore } from './installation-stores';
import defaultRenderHtmlForInstallPath from './default-render-html-for-install-path';
import { InstallPathOptions } from './install-path-options';
import { LogLevel, Logger, getLogger } from './logger';
import { ClearStateStore, StateStore } from './state-stores';

/**
* InstallProvider Class. Refer to InsallProviderOptions interface for the details of constructor arguments.
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/install-url-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import { describe, it } from 'mocha';

import { InstallURLOptions } from './install-url-options';

describe('InstallURLOptions', async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/installation-query.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import { describe, it } from 'mocha';

import { InstallationQuery } from './installation-query';

describe('InstallationQuery', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/oauth/src/installation-stores/file-store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs';
import path from 'path';
import { homedir } from 'os';
import { Installation, InstallationStore, InstallationQuery } from '../index';
import path from 'path';

import { Installation, InstallationQuery, InstallationStore } from '../index';
import { Logger } from '../logger';

export interface FileInstallationOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/installation-stores/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Logger } from '@slack/logger';

import { Installation, InstallationQuery } from '..';

export interface InstallationStore {
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth/src/installation-stores/memory-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Installation, InstallationStore, InstallationQuery, OrgInstallation } from '../index';
import { Installation, InstallationQuery, InstallationStore, OrgInstallation } from '../index';
import { Logger } from '../logger';

// using a javascript object as a makeshift database for development
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/installation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import { describe, it } from 'mocha';

import { Installation } from './installation';

describe('Installation', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Logger, LogLevel, ConsoleLogger } from '@slack/logger';
import { ConsoleLogger, LogLevel, Logger } from '@slack/logger';

export { Logger, LogLevel } from '@slack/logger';

Expand Down
5 changes: 3 additions & 2 deletions packages/oauth/src/state-stores/clear-state-store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { sign, verify } from 'jsonwebtoken';
import { InstallURLOptions } from '../install-url-options';
import { StateStore, StateObj } from './interface';

import { StateObj, StateStore } from './interface';
import { InvalidStateError } from '../errors';
import { InstallURLOptions } from '../install-url-options';

// default implementation of StateStore
export default class ClearStateStore implements StateStore {
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/state-stores/file-state-store.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os from 'os';

import { FileStateStore } from './file-state-store';
import { StateStoreChaiTestRunner } from './spec-utils';

Expand Down
8 changes: 5 additions & 3 deletions packages/oauth/src/state-stores/file-state-store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { homedir } from 'os';
import fs from 'fs';
import { homedir } from 'os';
import path from 'path';

import { ConsoleLogger, Logger } from '@slack/logger';
import { StateStore, StateObj } from './interface';
import { InstallURLOptions } from '../install-url-options';

import { StateObj, StateStore } from './interface';
import { InvalidStateError } from '../errors';
import { InstallURLOptions } from '../install-url-options';

export interface FileStateStoreArgs {
stateExpirationSeconds?: number;
Expand Down
1 change: 1 addition & 0 deletions packages/oauth/src/state-stores/spec-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-extraneous-dependencies */
import { assert } from 'chai';

import { StateStore } from './interface';
import { InstallURLOptions } from '../install-url-options';

Expand Down
5 changes: 3 additions & 2 deletions packages/rtm-api/src/KeepAlive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EventEmitter } from 'eventemitter3';
import { RTMClient } from './RTMClient';

import { CodedError, ErrorCode } from './errors';
import { LogLevel, Logger, getLogger } from './logger';
import { ErrorCode, CodedError } from './errors';
import { RTMClient } from './RTMClient';

export interface KeepAliveOptions {
logger?: Logger;
Expand Down
Loading

0 comments on commit fc87d51

Please sign in to comment.