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

Request: continuation indent on hanging line #661

Open
bwbb opened this issue Sep 6, 2024 · 0 comments
Open

Request: continuation indent on hanging line #661

bwbb opened this issue Sep 6, 2024 · 0 comments

Comments

@bwbb
Copy link

bwbb commented Sep 6, 2024

Consider the following code:

const httpClient = {
  ...axios,
  postDataWithAuthToken<T = any, R = AxiosResponse<T>, D = any>(url: string, data: D, authToken?: string): Promise<R> {
    const config: any = {
      headers: { ...baseHeaders },
    };

    if (authToken) {
      config.headers.Authorization = `Bearer ${authToken}`;
    }

    return axios.post(url, data, config);
  },
};

Formatted as follows:

{
  "lineWidth": 100,
  "bracePosition": "maintain",
  "operatorPosition": "nextLine",
  "preferHanging": true,
  "preferSingleLine": false,
  ... 
}

const httpClient = {
	...axios,
	postDataWithAuthToken<T = any, R = AxiosResponse<T>, D = any>(url: string, data: D,
		authToken?: string): Promise<R> {
		const config: any = {
			headers: { ...baseHeaders },
		};

		if (authToken) {
			config.headers.Authorization = `Bearer ${authToken}`;
		}

		return axios.post(url, data);
	},
};

It would be nice to have an extra indent on line 4 of the formatted code, for better readability. In editorconfig and Jetbrains products, this feature is called continuation_indent_size.
Also please add a feature to optionally have a new line after the hanging line. With these settings applied, the formatted code would like like this:

const httpClient = {
	...axios,
	postDataWithAuthToken<T = any, R = AxiosResponse<T>, D = any>(url: string, data: D,
			authToken?: string): Promise<R> {
			
		const config: any = {
			headers: { ...baseHeaders },
		};

		if (authToken) {
			config.headers.Authorization = `Bearer ${authToken}`;
		}

		return axios.post(url, data);
	},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant