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: sort imports #99

Merged
merged 1 commit into from
Feb 1, 2022
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
23 changes: 23 additions & 0 deletions e2e/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"plugins": [
"@typescript-eslint",
"simple-import-sort",
"unicorn",
"promise",
"prettier",
Expand All @@ -26,6 +27,28 @@
],
"rules": {
"import/order": "error",
"simple-import-sort/imports": ["error", {
"groups": [
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
],
// Packages. `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@|@company|@ui|components|utils|config|vendored-lib)(/.*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"]
]
}],
"simple-import-sort/exports": "error",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unpublished-import": "off",
"unicorn/numeric-separators-style": "off",
Expand Down
2 changes: 2 additions & 0 deletions e2e/helpers/authorization-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as querystring from 'querystring';

import { Page } from 'playwright-chromium';

import { User } from '../types';

export default async (
Expand Down
1 change: 1 addition & 0 deletions e2e/helpers/grants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page } from 'playwright-chromium';

import { User } from '../types';

export default async (page: Page, user: User): Promise<void> => {
Expand Down
12 changes: 5 additions & 7 deletions e2e/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import authorizationEndpoint from './authorization-endpoint';
import grants from './grants';
import introspectEndpoint from './introspect-endpoint';
import tokenEndpoint from './token-endpoint';
import userInfoEndpoint from './user-info-endpoint';

export { authorizationEndpoint, introspectEndpoint, grants, tokenEndpoint, userInfoEndpoint };
export { default as authorizationEndpoint } from './authorization-endpoint';
export { default as grants } from './grants';
export { default as introspectEndpoint } from './introspect-endpoint';
export { default as tokenEndpoint } from './token-endpoint';
export { default as userInfoEndpoint } from './user-info-endpoint';
2 changes: 2 additions & 0 deletions e2e/helpers/introspect-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as querystring from 'querystring';

import axios, { AxiosRequestConfig } from 'axios';

import apiResources from '../config/api-resources.json';

export default async (
Expand Down
1 change: 1 addition & 0 deletions e2e/helpers/token-endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as querystring from 'querystring';

import axios from 'axios';
import { decode as decodeJWT } from 'jws';

Expand Down
17 changes: 17 additions & 0 deletions e2e/package-lock.json

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

1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-promise": "5.1.1",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unicorn": "39.0.0",
"husky": "7.0.4",
"jest": "27.4.0",
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/base-path.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as querystring from 'querystring';
import * as dotenv from 'dotenv';

import axios from 'axios';
import * as dotenv from 'dotenv';

import clients from '../config/clients-configuration.json';
import type { Client } from '../types';
Expand Down
5 changes: 2 additions & 3 deletions e2e/tests/custom-endpoints/user-management.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as dotenv from 'dotenv';

import axios from 'axios';
import Chance from 'chance';
import { Client, User } from '../../types';
import * as dotenv from 'dotenv';

import clients from '../../config/clients-configuration.json';
import { introspectEndpoint, tokenEndpoint, userInfoEndpoint } from '../../helpers';
import { Client, User } from '../../types';

describe('User management', () => {
const chance = new Chance();
Expand Down
7 changes: 4 additions & 3 deletions e2e/tests/flows/authorization-code-pkce.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as crypto from 'crypto';

import * as dotenv from 'dotenv';
import { chromium, Page, Browser } from 'playwright-chromium';
import { Browser, chromium, Page } from 'playwright-chromium';

import type { User, Client } from '../../types';
import users from '../../config/user-configuration.json';
import clients from '../../config/clients-configuration.json';
import users from '../../config/user-configuration.json';
import { authorizationEndpoint, introspectEndpoint, tokenEndpoint, userInfoEndpoint } from '../../helpers';
import type { Client, User } from '../../types';

const testCases: User[] = users
.map(u => ({
Expand Down
6 changes: 3 additions & 3 deletions e2e/tests/flows/authorization-code.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as dotenv from 'dotenv';
import { chromium, Page, Browser } from 'playwright-chromium';
import { Browser, chromium, Page } from 'playwright-chromium';

import type { User, Client } from '../../types';
import users from '../../config/user-configuration.json';
import clients from '../../config/clients-configuration.json';
import users from '../../config/user-configuration.json';
import { authorizationEndpoint, introspectEndpoint, tokenEndpoint, userInfoEndpoint } from '../../helpers';
import type { Client, User } from '../../types';

const testCases: User[] = users
.map(u => ({
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/flows/client-credentials-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as dotenv from 'dotenv';

import clients from '../../config/clients-configuration.json';
import type { Client } from '../../types';
import { introspectEndpoint, tokenEndpoint } from '../../helpers';
import type { Client } from '../../types';

describe('Client Credentials Flow', () => {
let client: Client;
Expand Down
11 changes: 6 additions & 5 deletions e2e/tests/flows/implicit-flow.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as querystring from 'querystring';

import * as dotenv from 'dotenv';
import { decode as decodeJWT } from 'jws';
import { chromium, Page, Browser } from 'playwright-chromium';
import { Browser, chromium, Page } from 'playwright-chromium';

import type { User, Client } from '../../types';
import users from '../../config/user-configuration.json';
import clients from '../../config/clients-configuration.json';
import users from '../../config/user-configuration.json';
import { authorizationEndpoint, introspectEndpoint, userInfoEndpoint } from '../../helpers';
import type { Client, User } from '../../types';

const testCases: User[] = users
.map(u => ({
Expand Down Expand Up @@ -59,7 +60,7 @@ describe('Implicit Flow', () => {
const query = querystring.parse(hash);

const tokenParameter = query['access_token'];
expect(typeof tokenParameter).toEqual('string');
expect(typeof tokenParameter).toBe('string');
token = tokenParameter as string;
const decodedAccessToken = decodeJWT(token);
expect(decodedAccessToken).toMatchSnapshot();
Expand Down Expand Up @@ -87,7 +88,7 @@ describe('Implicit Flow', () => {
const query = querystring.parse(hash);

const tokenParameter = query['id_token'];
expect(typeof tokenParameter).toEqual('string');
expect(typeof tokenParameter).toBe('string');
token = tokenParameter as string;
const decodedAccessToken = decodeJWT(token);
expect(decodedAccessToken).toMatchSnapshot();
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/flows/password-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as dotenv from 'dotenv';

import users from '../../config/user-configuration.json';
import clients from '../../config/clients-configuration.json';
import type { Client, User } from '../../types';
import users from '../../config/user-configuration.json';
import { introspectEndpoint, tokenEndpoint, userInfoEndpoint } from '../../helpers';
import type { Client, User } from '../../types';

const testCases: User[] = users
.map(u => ({
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/https.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Agent } from 'https';
import * as dotenv from 'dotenv';

import axios from 'axios';
import * as dotenv from 'dotenv';

describe('Https', () => {
beforeAll(() => {
Expand Down
10 changes: 4 additions & 6 deletions e2e/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Claim from './claim';
import ApiResource from './api-resource';
import Client from './client';
import User from './user';

export { ApiResource, Claim, Client, User };
export { default as ApiResource } from './api-resource';
export { default as Claim } from './claim';
export { default as Client } from './client';
export { default as User } from './user';