@storm-software/eslint 0.125.0 → 0.126.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,9 +45,9 @@ __name(getLeadingComments, "getLeadingComments");
45
45
  function genCommentBody(commentType, textArray, eol, numNewlines) {
46
46
  const eols = eol.repeat(numNewlines);
47
47
  if (commentType === "block") {
48
- return "/* " + textArray.join(eol) + " */" + eols;
48
+ return "/*" + textArray.join(eol) + "*/" + eols;
49
49
  } else {
50
- return "// " + textArray.join(eol + " //") + eols;
50
+ return "//" + textArray.join(eol + "//") + eols;
51
51
  }
52
52
  }
53
53
  __name(genCommentBody, "genCommentBody");
@@ -85,22 +85,22 @@ function getEOL(options) {
85
85
  return os.EOL;
86
86
  }
87
87
  __name(getEOL, "getEOL");
88
- function hasBanner(commentType, src) {
88
+ function hasBanner(commentType = "block", src, eol) {
89
89
  if (src.startsWith("#!")) {
90
- const bannerLines = src.split(/\r?\n/);
90
+ const bannerLines = src.split(eol);
91
91
  if (bannerLines && bannerLines.length > 1) {
92
92
  bannerLines.shift();
93
- while (bannerLines.length && bannerLines[0] && !bannerLines[0].replace(/\s+/, "")) {
93
+ while (bannerLines.length && bannerLines[0] && !bannerLines[0].trim()) {
94
94
  bannerLines.shift();
95
95
  }
96
96
  if (bannerLines.length) {
97
- src = bannerLines.join("\n");
97
+ src = bannerLines.join(eol);
98
98
  } else {
99
99
  return false;
100
100
  }
101
101
  }
102
102
  }
103
- return commentType === "block" && src.startsWith("/*") || commentType === "lint" && src.startsWith("//") || commentType !== "block" && commentType !== "lint" && commentType && src.startsWith(commentType);
103
+ return commentType === "block" && src.startsWith("/*") || commentType === "line" && src.startsWith("//") || commentType !== "block" && commentType !== "line" && commentType && src.startsWith(commentType);
104
104
  }
105
105
  __name(hasBanner, "hasBanner");
106
106
  function matchesLineEndings(src, num) {
@@ -119,7 +119,7 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
119
119
  name: "banner",
120
120
  meta: {
121
121
  docs: {
122
- description: "Ensures the file has a Storm Software banner"
122
+ description: "Ensures the file has a organization specific banner at the top of source code files"
123
123
  },
124
124
  schema: [
125
125
  {
@@ -139,7 +139,15 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
139
139
  },
140
140
  numNewlines: {
141
141
  type: "number",
142
- description: "The number of newlines to use after the banner. Defaults to 2"
142
+ description: "The number of newlines to use after the banner. Defaults to 1"
143
+ },
144
+ lineEndings: {
145
+ type: "string",
146
+ enum: [
147
+ "unix",
148
+ "windows"
149
+ ],
150
+ description: "The type of line endings to use. Defaults to the system default"
143
151
  }
144
152
  },
145
153
  additionalProperties: false
@@ -158,21 +166,25 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
158
166
  {
159
167
  repositoryName: "",
160
168
  commentType: "block",
161
- numNewlines: 2
169
+ numNewlines: 1,
170
+ lineEndings: "unix"
162
171
  }
163
172
  ],
164
- create(context, [{ banner, repositoryName = "", commentType = "block", numNewlines = 2 }]) {
173
+ create(context, [{ banner, repositoryName = "", commentType = "block", numNewlines = 1, lineEndings = "unix" }]) {
165
174
  if (!banner) {
166
175
  banner = getFileBanner(repositoryName);
167
176
  }
168
177
  const options = context.options;
169
- const eol = getEOL(options);
178
+ const eol = getEOL({
179
+ lineEndings,
180
+ ...options
181
+ });
170
182
  const canFix = true;
171
183
  const bannerLines = banner.split(/\r?\n/);
172
184
  let fixLines = bannerLines;
173
185
  return {
174
186
  Program: /* @__PURE__ */ __name(function(node) {
175
- if (!hasBanner(commentType, context.sourceCode.getText())) {
187
+ if (!hasBanner(commentType, context.sourceCode.getText(), eol)) {
176
188
  context.report({
177
189
  loc: node.loc,
178
190
  messageId: "missingBanner",
@@ -0,0 +1,24 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-SHUYVCID.js";
4
+
5
+ // src/utils/tsconfig-path.ts
6
+ import { existsSync } from "node:fs";
7
+ function getTsConfigPath() {
8
+ let tsconfigPath = "tsconfig.json";
9
+ if (existsSync("tsconfig.base.json")) {
10
+ tsconfigPath = "tsconfig.base.json";
11
+ } else if (existsSync("tsconfig.app.json")) {
12
+ tsconfigPath = "tsconfig.app.json";
13
+ } else if (existsSync("tsconfig.lib.json")) {
14
+ tsconfigPath = "tsconfig.lib.json";
15
+ } else {
16
+ console.warn("No tsconfig.json found. Consider adding a tsconfig.json file to your project's ESLint configuration.");
17
+ }
18
+ return tsconfigPath;
19
+ }
20
+ __name(getTsConfigPath, "getTsConfigPath");
21
+
22
+ export {
23
+ getTsConfigPath
24
+ };
package/dist/preset.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Linter } from 'eslint';
2
2
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
3
- import { O as OptionsConfig, R as RuleOptions, T as TypedFlatConfigItem, A as Awaitable, C as ConfigNames } from './types-Bz2mGFHi.js';
3
+ import { O as OptionsConfig, R as RuleOptions, T as TypedFlatConfigItem, A as Awaitable, C as ConfigNames } from './types-oCxTBmlp.js';
4
4
  import '@nx/eslint-plugin/src/utils/runtime-lint-utils';
5
5
  import '@stylistic/eslint-plugin';
6
6
  import '@typescript-eslint/parser';
package/dist/preset.js CHANGED
@@ -1,6 +1,9 @@
1
+ import {
2
+ getTsConfigPath
3
+ } from "./chunk-GXNMSXDL.js";
1
4
  import {
2
5
  banner_plugin_default
3
- } from "./chunk-QX5WDYBX.js";
6
+ } from "./chunk-BXVDD33Y.js";
4
7
  import "./chunk-KDHZD7SF.js";
5
8
  import {
6
9
  GLOB_ASTRO,
@@ -163,6 +166,9 @@ async function disables() {
163
166
  }
164
167
  __name(disables, "disables");
165
168
 
169
+ // src/configs/formatters.ts
170
+ import defu from "defu";
171
+
166
172
  // src/configs/stylistic.ts
167
173
  var StylisticConfigDefaults = {
168
174
  indent: 2,
@@ -171,7 +177,7 @@ var StylisticConfigDefaults = {
171
177
  semi: true
172
178
  };
173
179
  async function stylistic(options = {}) {
174
- const { indent, jsx: jsx2, overrides = {}, quotes, semi } = {
180
+ const { indent = 2, jsx: jsx2 = true, overrides = {}, quotes = "double", semi = true, lineEndings = "unix" } = {
175
181
  ...StylisticConfigDefaults,
176
182
  ...options
177
183
  };
@@ -192,6 +198,10 @@ async function stylistic(options = {}) {
192
198
  rules: {
193
199
  ...config.rules,
194
200
  "style/lines-around-comment": "off",
201
+ "style/linebreak-style": [
202
+ "error",
203
+ lineEndings
204
+ ],
195
205
  // "style/padding-line-between-statements": [
196
206
  // "error",
197
207
  // { blankLine: "always", prev: ["const", "let", "var"], next: "*" },
@@ -238,30 +248,35 @@ async function formatters(options = {}, stylistic2 = {}) {
238
248
  options.astro ? "prettier-plugin-astro" : void 0,
239
249
  options.xml || options.svg ? "@prettier/plugin-xml" : void 0
240
250
  ]);
241
- const { indent, quotes, semi } = {
251
+ const { indent = 2, quotes = "double", semi = true } = {
242
252
  ...StylisticConfigDefaults,
243
253
  ...stylistic2
244
254
  };
245
- const prettierOptions = Object.assign({
246
- endOfLine: "auto",
255
+ const prettierOptions = defu({
256
+ proseWrap: "always",
257
+ quoteProps: "preserve",
258
+ bracketSameLine: true,
259
+ bracketSpacing: true,
260
+ arrowParens: "avoid",
261
+ endOfLine: "lf",
247
262
  printWidth: 120,
248
263
  semi,
249
264
  singleQuote: quotes === "single",
250
265
  tabWidth: typeof indent === "number" ? indent : 2,
251
- trailingComma: "all",
266
+ trailingComma: "none",
252
267
  useTabs: indent === "tab"
253
- }, options.prettierOptions || {});
268
+ }, options.prettierOptions ?? {});
254
269
  const prettierXmlOptions = {
255
270
  xmlQuoteAttributes: "double",
256
271
  xmlSelfClosingSpace: true,
257
272
  xmlSortAttributesByKey: false,
258
273
  xmlWhitespaceSensitivity: "ignore"
259
274
  };
260
- const dprintOptions = Object.assign({
275
+ const dprintOptions = defu({
261
276
  indentWidth: typeof indent === "number" ? indent : 2,
262
277
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
263
278
  useTabs: indent === "tab"
264
- }, options.dprintOptions || {});
279
+ }, options.dprintOptions ?? {});
265
280
  const pluginFormat = await interopDefault(import("eslint-plugin-format"));
266
281
  const configs2 = [
267
282
  {
@@ -767,16 +782,16 @@ async function imports(options = {}) {
767
782
  __name(imports, "imports");
768
783
 
769
784
  // src/configs/javascript.ts
770
- import defu from "defu";
785
+ import defu2 from "defu";
771
786
  import globalsLib from "globals";
772
787
  async function javascript(options = {}) {
773
- const { isInEditor = false, overrides = {}, name = "storm", globals = {} } = options;
788
+ const { isInEditor = false, lineEndings = "unix", overrides = {}, name = "", globals = {} } = options;
774
789
  return [
775
790
  {
776
791
  name: "storm/javascript/setup",
777
792
  languageOptions: {
778
793
  ecmaVersion: 2022,
779
- globals: defu(globals, {
794
+ globals: defu2(globals, {
780
795
  ...globalsLib.browser,
781
796
  ...globalsLib.es2021,
782
797
  ...globalsLib.node,
@@ -809,8 +824,9 @@ async function javascript(options = {}) {
809
824
  "error",
810
825
  {
811
826
  commentType: "block",
812
- numNewlines: 2,
813
- repositoryName: name
827
+ numNewlines: 1,
828
+ repositoryName: name,
829
+ lineEndings
814
830
  }
815
831
  ]
816
832
  }
@@ -2459,7 +2475,7 @@ async function node() {
2459
2475
  __name(node, "node");
2460
2476
 
2461
2477
  // src/configs/nx.ts
2462
- import defu2 from "defu";
2478
+ import defu3 from "defu";
2463
2479
  async function nx(options = {}) {
2464
2480
  const { depsCheck, moduleBoundaries } = options;
2465
2481
  return [
@@ -2487,7 +2503,7 @@ async function nx(options = {}) {
2487
2503
  rules: {
2488
2504
  "@nx/dependency-checks": [
2489
2505
  "error",
2490
- defu2(depsCheck ?? {}, {
2506
+ defu3(depsCheck ?? {}, {
2491
2507
  buildTargets: [
2492
2508
  "build-base",
2493
2509
  "build"
@@ -3223,7 +3239,6 @@ async function toml(options = {}) {
3223
3239
  __name(toml, "toml");
3224
3240
 
3225
3241
  // src/configs/typescript.ts
3226
- import { existsSync } from "node:fs";
3227
3242
  import process from "node:process";
3228
3243
  async function typescript(options = {}) {
3229
3244
  const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
@@ -3240,19 +3255,9 @@ async function typescript(options = {}) {
3240
3255
  `${GLOB_MARKDOWN}/**`,
3241
3256
  GLOB_ASTRO_TS
3242
3257
  ];
3243
- let tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
3258
+ let tsconfigPath = options?.tsconfigPath;
3244
3259
  if (!tsconfigPath) {
3245
- if (existsSync("tsconfig.json")) {
3246
- tsconfigPath = "tsconfig.json";
3247
- } else if (existsSync("tsconfig.base.json")) {
3248
- tsconfigPath = "tsconfig.base.json";
3249
- } else if (existsSync("tsconfig.app.json")) {
3250
- tsconfigPath = "tsconfig.app.json";
3251
- } else if (existsSync("tsconfig.lib.json")) {
3252
- tsconfigPath = "tsconfig.lib.json";
3253
- } else {
3254
- console.warn("No tsconfig.json found. Consider adding a tsconfig.json file to your project's ESLint configuration.");
3255
- }
3260
+ tsconfigPath = getTsConfigPath();
3256
3261
  }
3257
3262
  const isTypeAware = !!tsconfigPath;
3258
3263
  const typeAwareRules = {
@@ -3342,10 +3347,10 @@ async function typescript(options = {}) {
3342
3347
  files,
3343
3348
  name: "storm/typescript/rules",
3344
3349
  rules: {
3345
- ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, {
3350
+ ...renameRules(pluginTs.configs["eslint-recommended"]?.overrides?.[0]?.rules, {
3346
3351
  "@typescript-eslint": "ts"
3347
3352
  }),
3348
- ...renameRules(pluginTs.configs.strict.rules, {
3353
+ ...renameRules(pluginTs.configs.strict?.rules, {
3349
3354
  "@typescript-eslint": "ts"
3350
3355
  }),
3351
3356
  /*************************************************************
@@ -3727,12 +3732,12 @@ function getOverrides(options, key) {
3727
3732
  }
3728
3733
  __name(getOverrides, "getOverrides");
3729
3734
  function getStormConfig(options, ...userConfigs) {
3730
- const { name, globals = {}, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, cspell: enableCSpell = true, react: enableReact = false, regexp: enableRegexp = true, next: enableNext = false, graphql: enableGraphQL = false, storybook: enableStorybook = false, typescript: enableTypeScript = isPackageExists2("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false } = options;
3735
+ const { name = "", globals = {}, lineEndings = "unix", astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, cspell: enableCSpell = true, react: enableReact = false, regexp: enableRegexp = true, next: enableNext = false, graphql: enableGraphQL = false, storybook: enableStorybook = false, typescript: enableTypeScript = isPackageExists2("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false } = options;
3731
3736
  let isInEditor = options.isInEditor;
3732
3737
  if (isInEditor == null) {
3733
3738
  isInEditor = isInEditorEnv();
3734
3739
  if (isInEditor)
3735
- console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
3740
+ console.log("[@storm-software/eslint] Detected running in editor, some rules are disabled.");
3736
3741
  }
3737
3742
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
3738
3743
  if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
@@ -3755,10 +3760,14 @@ function getStormConfig(options, ...userConfigs) {
3755
3760
  }
3756
3761
  }
3757
3762
  const typescriptOptions = resolveSubOptions(options, "typescript");
3758
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
3763
+ let tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
3764
+ if (!tsconfigPath) {
3765
+ tsconfigPath = getTsConfigPath();
3766
+ }
3759
3767
  configs2.push(ignores(options.ignores), javascript({
3760
3768
  name,
3761
3769
  globals,
3770
+ lineEndings,
3762
3771
  isInEditor,
3763
3772
  overrides: getOverrides(options, "javascript")
3764
3773
  }), node(), jsdoc({
@@ -3786,6 +3795,7 @@ function getStormConfig(options, ...userConfigs) {
3786
3795
  if (stylisticOptions) {
3787
3796
  configs2.push(stylistic({
3788
3797
  ...stylisticOptions,
3798
+ lineEndings,
3789
3799
  lessOpinionated: options.lessOpinionated,
3790
3800
  overrides: getOverrides(options, "stylistic")
3791
3801
  }));
@@ -320,7 +320,7 @@ interface RuleOptions {
320
320
  */
321
321
  'astro/valid-compile'?: Linter.RuleEntry<[]>
322
322
  /**
323
- * Ensures the file has a Storm Software banner
323
+ * Ensures the file has a organization specific banner at the top of source code files
324
324
  * @see https://docs.stormsoftware.com/eslint/rules/banner
325
325
  */
326
326
  'banner/banner'?: Linter.RuleEntry<BannerBanner>
@@ -6740,6 +6740,8 @@ type BannerBanner = []|[{
6740
6740
  commentType?: string
6741
6741
 
6742
6742
  numNewlines?: number
6743
+
6744
+ lineEndings?: ("unix" | "windows")
6743
6745
  }]
6744
6746
  // ----- block-spacing -----
6745
6747
  type BlockSpacing = []|[("always" | "never")]
@@ -14870,7 +14872,9 @@ interface OptionsTypeScriptWithTypes {
14870
14872
  */
14871
14873
  overridesTypeAware?: TypedFlatConfigItem["rules"];
14872
14874
  }
14873
- type StylisticConfig = Pick<StylisticCustomizeOptions, "indent" | "quotes" | "jsx" | "semi">;
14875
+ type StylisticConfig = Pick<StylisticCustomizeOptions, "indent" | "quotes" | "jsx" | "semi"> & {
14876
+ lineEndings?: "unix" | "windows";
14877
+ };
14874
14878
  interface OptionsOverrides {
14875
14879
  overrides?: TypedFlatConfigItem["rules"];
14876
14880
  }
@@ -15089,6 +15093,12 @@ interface OptionsJavascript {
15089
15093
  * An object containing a list of extra global variables to include in the configuration.
15090
15094
  */
15091
15095
  globals?: Record<string, ESLintGlobalsPropValue>;
15096
+ /**
15097
+ * The style of line endings to use.
15098
+ *
15099
+ * @default "unix"
15100
+ */
15101
+ lineEndings?: "unix" | "windows";
15092
15102
  }
15093
15103
  interface OptionsConfig extends OptionsComponentExts, OptionsJavascript, OptionsProjectType {
15094
15104
  /**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  banner_plugin_default
3
- } from "../chunk-QX5WDYBX.js";
3
+ } from "../chunk-BXVDD33Y.js";
4
4
  import "../chunk-KDHZD7SF.js";
5
5
  import "../chunk-AIKLBIPC.js";
6
6
  import "../chunk-SHUYVCID.js";
@@ -1,5 +1,5 @@
1
1
  import { Awaitable } from 'eslint-flat-config-utils';
2
- import { T as TypedFlatConfigItem } from '../types-Bz2mGFHi.js';
2
+ import { T as TypedFlatConfigItem } from '../types-oCxTBmlp.js';
3
3
  import '@nx/eslint-plugin/src/utils/runtime-lint-utils';
4
4
  import '@stylistic/eslint-plugin';
5
5
  import '@typescript-eslint/parser';
@@ -0,0 +1,3 @@
1
+ declare function getTsConfigPath(): string;
2
+
3
+ export { getTsConfigPath };
@@ -0,0 +1,7 @@
1
+ import {
2
+ getTsConfigPath
3
+ } from "../chunk-GXNMSXDL.js";
4
+ import "../chunk-SHUYVCID.js";
5
+ export {
6
+ getTsConfigPath
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/eslint",
3
- "version": "0.125.0",
3
+ "version": "0.126.0",
4
4
  "type": "module",
5
5
  "description": "⚡ A package containing the base ESLint configuration used by Storm Software across many projects.",
6
6
  "repository": {