Skip to content

Commit 743188b

Browse files
committed
refactor: Add lines-around-comment rule
I often struggle with spacing around block comments, so I've decided to add the `lines-around-comment` lint rule to help manage this. For more details, see the https://eslint.style/rules/js/lines-around-comment
1 parent 6c6248e commit 743188b

File tree

28 files changed

+122
-5
lines changed

28 files changed

+122
-5
lines changed

.eslintrc.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,24 @@
3333
"project": "tsconfig.json",
3434
"sourceType": "module"
3535
},
36-
"plugins": ["eslint-plugin-import", "header", "@typescript-eslint"],
36+
"plugins": ["@stylistic", "@typescript-eslint", "eslint-plugin-import", "header"],
3737
"rules": {
38+
"@stylistic/lines-around-comment": [
39+
"error",
40+
{
41+
"allowArrayStart": true,
42+
"allowBlockStart": true,
43+
"allowClassStart": true,
44+
"allowEnumStart": true,
45+
"allowInterfaceStart": true,
46+
"allowModuleStart": true,
47+
"allowObjectStart": true,
48+
"allowTypeStart": true,
49+
"beforeBlockComment": true,
50+
"ignorePattern": "@license"
51+
}
52+
],
53+
"@stylistic/spaced-comment": ["error", "always"],
3854
"@typescript-eslint/consistent-type-assertions": "error",
3955
"@typescript-eslint/no-explicit-any": "error",
4056
"@typescript-eslint/no-non-null-assertion": "error",

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"@listr2/prompt-adapter-inquirer": "2.0.15",
9191
"@rollup/plugin-commonjs": "^26.0.0",
9292
"@rollup/plugin-node-resolve": "^13.0.5",
93+
"@stylistic/eslint-plugin": "^2.8.0",
9394
"@types/babel__core": "7.20.5",
9495
"@types/browser-sync": "^2.27.0",
9596
"@types/express": "^4.16.0",

packages/angular/build/src/builders/dev-server/vite-server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ function getDepOptimizationConfig({
709709
}
710710

711711
const nodeJsBuiltinModules = new Set(builtinModules);
712+
712713
/** Remove any Node.js builtin modules to avoid Vite's prebundling from processing them as files. */
713714
function removeNodeJsBuiltinModules(value: string): boolean {
714715
return !nodeJsBuiltinModules.has(value);

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface CompilerPluginOptions {
3939
sourcemap: boolean | 'external';
4040
tsconfig: string;
4141
jit?: boolean;
42+
4243
/** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
4344
noopTypeScriptCompilation?: boolean;
4445
advancedOptimizations?: boolean;

packages/angular/build/src/tools/esbuild/i18n-inliner-worker.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ interface InlineRequest {
2222
* during Worker initialization.
2323
*/
2424
filename: string;
25+
2526
/**
2627
* The locale specifier that should be used during the inlining process of the file.
2728
*/
2829
locale: string;
30+
2931
/**
3032
* The translation messages for the locale that should be used during the inlining process of the file.
3133
*/

packages/angular/build/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { LoadResultCache, createCachedLoad } from '../load-result-cache';
1818
export interface CssInlineFontsPluginOptions {
1919
/** Disk cache normalized options */
2020
cacheOptions?: NormalizedCachedOptions;
21+
2122
/** Load results cache. */
2223
cache?: LoadResultCache;
2324
}

packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.ts

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class StylesheetPluginFactory {
190190
}
191191

192192
private initPostcssCallCount = 0;
193+
193194
/**
194195
* This method should not be called directly.
195196
* Use {@link setupPostcss} instead.

packages/angular/build/src/tools/esbuild/virtual-module-plugin.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ import { LoadResultCache, createCachedLoad } from './load-result-cache';
1616
export interface VirtualModulePluginOptions {
1717
/** Namespace. Example: `angular:polyfills`. */
1818
namespace: string;
19+
1920
/** If the generated module should be marked as external. */
2021
external?: boolean;
22+
2123
/** Method to transform the onResolve path. */
2224
transformPath?: (path: string) => string;
25+
2326
/** Method to provide the module content. */
2427
loadContent: (
2528
args: OnLoadArgs,
2629
build: PluginBuild,
2730
) => ReturnType<Parameters<PluginBuild['onLoad']>[1]>;
31+
2832
/** Restrict to only entry points. Defaults to `true`. */
2933
entryPointOnly?: boolean;
34+
3035
/** Load results cache. */
3136
cache?: LoadResultCache;
3237
}

packages/angular/build/src/tools/esbuild/wasm-plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { LoadResultCache, createCachedLoad } from './load-result-cache';
2121
export interface WasmPluginOptions {
2222
/** Allow generation of async (proposal compliant) WASM imports. This requires zoneless to enable async/await. */
2323
allowAsync?: boolean;
24+
2425
/** Load results cache. */
2526
cache?: LoadResultCache;
2627
}

packages/angular/build/src/tools/sass/sass-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface SerializableVersion {
5252
export interface SerializableDeprecation extends Omit<Deprecation, 'obsoleteIn' | 'deprecatedIn'> {
5353
/** The version this deprecation first became active in. */
5454
deprecatedIn: SerializableVersion | null;
55+
5556
/** The version this deprecation became obsolete in. */
5657
obsoleteIn: SerializableVersion | null;
5758
}

packages/angular/build/src/tools/sass/worker.ts

+4
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ interface RenderRequestMessage {
3535
* The contents to compile.
3636
*/
3737
source: string;
38+
3839
/**
3940
* The Sass options to provide to the `dart-sass` compile function.
4041
*/
4142
options: Omit<StringOptions<'sync'>, 'url'> & { url: string };
43+
4244
/**
4345
* Indicates the request has a custom importer function on the main thread.
4446
*/
4547
importerChannel?: {
4648
port: MessagePort;
4749
signal: Int32Array;
4850
};
51+
4952
/**
5053
* Indicates the request has a custom logger for warning messages.
5154
*/
5255
hasLogger: boolean;
56+
5357
/**
5458
* Indicates paths within url() CSS functions should be rebased.
5559
*/

packages/angular/build/src/utils/index-file/augment-index-html.ts

+5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ export interface AugmentIndexHtmlOptions {
2424
baseHref?: string;
2525
deployUrl?: string;
2626
sri: boolean;
27+
2728
/** crossorigin attribute setting of elements that provide CORS support */
2829
crossOrigin?: CrossOriginValue;
30+
2931
/*
3032
* Files emitted by the build.
3133
*/
3234
files: FileInfo[];
35+
3336
/*
3437
* Function that loads a file used.
3538
* This allows us to use different routines within the IndexHtmlWebpackPlugin and
3639
* when used without this plugin.
3740
*/
3841
loadOutputFile: LoadOutputFileFunctionType;
42+
3943
/** Used to sort the inseration of files in the HTML file */
4044
entrypoints: Entrypoint[];
45+
4146
/** Used to set the document default locale */
4247
lang?: string;
4348
hints?: { url: string; mode: string; as?: string }[];

packages/angular/build/src/utils/index-file/valid-self-closing-tags.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const VALID_SELF_CLOSING_TAGS = new Set([
2222
'source',
2323
'track',
2424
'wbr',
25+
2526
/** SVG tags */
2627
'circle',
2728
'ellipse',
@@ -45,6 +46,7 @@ export const VALID_SELF_CLOSING_TAGS = new Set([
4546
'symbol',
4647
'use',
4748
'view',
49+
4850
/** MathML tags */
4951
'mspace',
5052
'mphantom',

packages/angular/build/src/utils/normalize-cache.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ const VERSION = '0.0.0-PLACEHOLDER';
1414
export interface NormalizedCachedOptions {
1515
/** Whether disk cache is enabled. */
1616
enabled: boolean;
17+
1718
/** Disk cache path. Example: `/.angular/cache/v12.0.0`. */
1819
path: string;
20+
1921
/** Disk cache base path. Example: `/.angular/cache`. */
2022
basePath: string;
2123
}

packages/angular/cli/src/command-builder/command-module.ts

+6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export type Options<T> = { [key in keyof T as CamelCaseKey<key>]: T[key] };
3333
export enum CommandScope {
3434
/** Command can only run inside an Angular workspace. */
3535
In,
36+
3637
/** Command can only run outside an Angular workspace. */
3738
Out,
39+
3840
/** Command can run inside and outside an Angular workspace. */
3941
Both,
4042
}
@@ -46,6 +48,7 @@ export interface CommandContext {
4648
globalConfiguration: AngularWorkspace;
4749
logger: logging.Logger;
4850
packageManager: PackageManagerUtils;
51+
4952
/** Arguments parsed in free-from without parser configuration. */
5053
args: {
5154
positional: string[];
@@ -63,10 +66,13 @@ export interface CommandModuleImplementation<T extends {} = {}>
6366
extends Omit<YargsCommandModule<{}, T>, 'builder' | 'handler'> {
6467
/** Scope in which the command can be executed in. */
6568
scope: CommandScope;
69+
6670
/** Path used to load the long description for the command in JSON help text. */
6771
longDescriptionPath?: string;
72+
6873
/** Object declaring the options the command accepts, or a function accepting and returning a yargs instance. */
6974
builder(argv: Argv): Promise<Argv<T>> | Argv<T>;
75+
7076
/** A function which will be passed the parsed argv. */
7177
run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
7278
}

packages/angular/cli/src/commands/update/cli.ts

+1
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
901901

902902
return success ? 0 : 1;
903903
}
904+
904905
/**
905906
* @return Whether or not the commit was successful.
906907
*/

packages/angular/ssr/node/src/common-engine/common-engine.ts

+5
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,30 @@ const SSG_MARKER_REGEXP = /ng-server-context=["']\w*\|?ssg\|?\w*["']/;
2323
export interface CommonEngineOptions {
2424
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
2525
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
26+
2627
/** A set of platform level providers for all requests. */
2728
providers?: StaticProvider[];
29+
2830
/** Enable request performance profiling data collection and printing the results in the server console. */
2931
enablePerformanceProfiler?: boolean;
3032
}
3133

3234
export interface CommonEngineRenderOptions {
3335
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
3436
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
37+
3538
/** A set of platform level providers for the current request. */
3639
providers?: StaticProvider[];
3740
url?: string;
3841
document?: string;
3942
documentFilePath?: string;
43+
4044
/**
4145
* Reduce render blocking requests by inlining critical CSS.
4246
* Defaults to true.
4347
*/
4448
inlineCriticalCss?: boolean;
49+
4550
/**
4651
* Base path location of index file.
4752
* Defaults to the 'documentFilePath' dirname when not provided.

packages/angular/ssr/src/routes/ng-routes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ interface RouteResult {
9292
async function* traverseRoutesConfig(options: {
9393
/** The array of route configurations to process. */
9494
routes: Route[];
95+
9596
/** The Angular compiler used to compile route modules. */
9697
compiler: Compiler;
98+
9799
/** The parent injector for lazy-loaded modules. */
98100
parentInjector: Injector;
101+
99102
/** The parent route path to prefix child routes. */
100103
parentRoute: string;
101104
}): AsyncIterableIterator<RouteResult> {

packages/angular/ssr/src/routes/route-config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface ServerRouteSSG extends Omit<ServerRouteCommon, 'status'> {
8383
* Defaults to `SSGFallback.SSR` if not provided.
8484
*/
8585
fallback?: SSGFallback;
86+
8687
/**
8788
* A function that returns a Promise resolving to an array of objects, each representing a route path with URL parameters.
8889
* This function runs in the injector context, allowing access to Angular services and dependencies.

packages/angular_devkit/architect/src/jobs/api.ts

+4
Original file line numberDiff line numberDiff line change
@@ -275,20 +275,24 @@ export enum JobState {
275275
* The job was queued and is waiting to start.
276276
*/
277277
Queued = 'queued',
278+
278279
/**
279280
* The job description was found, its dependencies (see "Synchronizing and Dependencies")
280281
* are done running, and the job's argument is validated and the job's code will be executed.
281282
*/
282283
Ready = 'ready',
284+
283285
/**
284286
* The job has been started. The job implementation is expected to send this as soon as its
285287
* work is starting.
286288
*/
287289
Started = 'started',
290+
288291
/**
289292
* The job has ended and is done running.
290293
*/
291294
Ended = 'ended',
295+
292296
/**
293297
* An error occured and the job stopped because of internal state.
294298
*/

packages/angular_devkit/build_angular/src/builders/app-shell/render-worker.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ interface RenderRequest {
4444
* The path to the server bundle that should be loaded and rendered.
4545
*/
4646
serverBundlePath: string;
47+
4748
/**
4849
* The existing HTML document as a string that will be augmented with the rendered application.
4950
*/
5051
document: string;
52+
5153
/**
5254
* An optional URL path that represents the Angular route that should be rendered.
5355
*/

packages/angular_devkit/build_angular/src/tools/webpack/plugins/javascript-optimizer-worker.ts

+7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ export interface OptimizeRequestOptions {
2222
* * terser pure_getters option is enabled
2323
*/
2424
advanced?: boolean;
25+
2526
/**
2627
* Specifies the string tokens that should be replaced with a defined value.
2728
*/
2829
define?: Record<string, string>;
30+
2931
/**
3032
* Controls whether class, function, and variable names should be left intact
3133
* throughout the output code.
@@ -37,15 +39,18 @@ export interface OptimizeRequestOptions {
3739
* Within the CLI, this option is linked to the license extraction functionality.
3840
*/
3941
removeLicenses?: boolean;
42+
4043
/**
4144
* Controls whether source maps should be generated.
4245
*/
4346
sourcemap?: boolean;
47+
4448
/**
4549
* Specifies the list of supported esbuild targets.
4650
* @see: https://esbuild.github.io/api/#target
4751
*/
4852
target?: string[];
53+
4954
/**
5055
* Controls whether esbuild should only use the WASM-variant instead of trying to
5156
* use the native variant. Some platforms may not support the native-variant and
@@ -71,10 +76,12 @@ interface OptimizeRequest {
7176
* The name of the JavaScript asset (typically the filename).
7277
*/
7378
name: string;
79+
7480
/**
7581
* The source content of the JavaScript asset.
7682
*/
7783
code: string;
84+
7885
/**
7986
* The source map of the JavaScript asset, if available.
8087
* This map is merged with all intermediate source maps during optimization.

packages/angular_devkit/build_angular/src/tools/webpack/plugins/postcss-cli-resources.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface PostcssCliResourcesOptions {
3030
deployUrl?: string;
3131
resourcesOutputPath?: string;
3232
rebaseRootRelative?: boolean;
33+
3334
/** CSS is extracted to a `.css` or is embedded in a `.js` file. */
3435
extracted?: boolean;
3536
filename: (resourcePath: string) => string;

packages/angular_devkit/build_angular/src/utils/normalize-cache.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ const VERSION = '0.0.0-PLACEHOLDER';
1414
export interface NormalizedCachedOptions {
1515
/** Whether disk cache is enabled. */
1616
enabled: boolean;
17+
1718
/** Disk cache path. Example: `/.angular/cache/v12.0.0`. */
1819
path: string;
20+
1921
/** Disk cache base path. Example: `/.angular/cache`. */
2022
basePath: string;
2123
}

0 commit comments

Comments
 (0)