@storm-software/eslint 0.124.3 → 0.125.1

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getFileBanner
3
- } from "./chunk-EEGFPU3P.js";
3
+ } from "./chunk-KDHZD7SF.js";
4
4
  import {
5
5
  GLOB_SRC
6
6
  } from "./chunk-AIKLBIPC.js";
@@ -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
+ };
@@ -26,7 +26,7 @@ var getFileBanner = /* @__PURE__ */ __name((name = "") => {
26
26
  return word.charAt(0).toUpperCase() + word.slice(1);
27
27
  }).join(" ");
28
28
  }
29
- return `-------------------------------------------------------------------
29
+ return ` -------------------------------------------------------------------
30
30
 
31
31
  ${padding}\u26A1 Storm Software ${titleName ? `- ${titleName}` : ""}
32
32
 
@@ -41,7 +41,7 @@ ${padding}\u26A1 Storm Software ${titleName ? `- ${titleName}` : ""}
41
41
  Contact: ${process.env.STORM_HOMEPAGE ? process.env.STORM_HOMEPAGE.endsWith("/") ? process.env.STORM_HOMEPAGE.slice(-1) : process.env.STORM_HOMEPAGE : "https://stormsoftware.com"}/contact
42
42
  License: ${process.env.STORM_LICENSING ? process.env.STORM_LICENSING : `https://stormsoftware.com/${name ? `projects/${name}/` : ""}license`}
43
43
 
44
- -------------------------------------------------------------------`;
44
+ ------------------------------------------------------------------- `;
45
45
  }, "getFileBanner");
46
46
 
47
47
  export {
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,7 +1,10 @@
1
+ import {
2
+ getTsConfigPath
3
+ } from "./chunk-GXNMSXDL.js";
1
4
  import {
2
5
  banner_plugin_default
3
- } from "./chunk-JOZDGLKT.js";
4
- import "./chunk-EEGFPU3P.js";
6
+ } from "./chunk-BXVDD33Y.js";
7
+ import "./chunk-KDHZD7SF.js";
5
8
  import {
6
9
  GLOB_ASTRO,
7
10
  GLOB_ASTRO_TS,
@@ -171,7 +174,7 @@ var StylisticConfigDefaults = {
171
174
  semi: true
172
175
  };
173
176
  async function stylistic(options = {}) {
174
- const { indent, jsx: jsx2, overrides = {}, quotes, semi } = {
177
+ const { indent, jsx: jsx2, overrides = {}, quotes, semi, lineEndings = "unix" } = {
175
178
  ...StylisticConfigDefaults,
176
179
  ...options
177
180
  };
@@ -192,6 +195,10 @@ async function stylistic(options = {}) {
192
195
  rules: {
193
196
  ...config.rules,
194
197
  "style/lines-around-comment": "off",
198
+ "style/linebreak-style": [
199
+ "error",
200
+ lineEndings
201
+ ],
195
202
  // "style/padding-line-between-statements": [
196
203
  // "error",
197
204
  // { blankLine: "always", prev: ["const", "let", "var"], next: "*" },
@@ -770,7 +777,7 @@ __name(imports, "imports");
770
777
  import defu from "defu";
771
778
  import globalsLib from "globals";
772
779
  async function javascript(options = {}) {
773
- const { isInEditor = false, overrides = {}, name = "storm", globals = {} } = options;
780
+ const { isInEditor = false, lineEndings = "unix", overrides = {}, name = "", globals = {} } = options;
774
781
  return [
775
782
  {
776
783
  name: "storm/javascript/setup",
@@ -809,8 +816,9 @@ async function javascript(options = {}) {
809
816
  "error",
810
817
  {
811
818
  commentType: "block",
812
- numNewlines: 2,
813
- repositoryName: name
819
+ numNewlines: 1,
820
+ repositoryName: name,
821
+ lineEndings
814
822
  }
815
823
  ]
816
824
  }
@@ -3223,7 +3231,6 @@ async function toml(options = {}) {
3223
3231
  __name(toml, "toml");
3224
3232
 
3225
3233
  // src/configs/typescript.ts
3226
- import { existsSync } from "node:fs";
3227
3234
  import process from "node:process";
3228
3235
  async function typescript(options = {}) {
3229
3236
  const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
@@ -3240,19 +3247,9 @@ async function typescript(options = {}) {
3240
3247
  `${GLOB_MARKDOWN}/**`,
3241
3248
  GLOB_ASTRO_TS
3242
3249
  ];
3243
- let tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
3250
+ let tsconfigPath = options?.tsconfigPath;
3244
3251
  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
- }
3252
+ tsconfigPath = getTsConfigPath();
3256
3253
  }
3257
3254
  const isTypeAware = !!tsconfigPath;
3258
3255
  const typeAwareRules = {
@@ -3727,12 +3724,12 @@ function getOverrides(options, key) {
3727
3724
  }
3728
3725
  __name(getOverrides, "getOverrides");
3729
3726
  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;
3727
+ 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
3728
  let isInEditor = options.isInEditor;
3732
3729
  if (isInEditor == null) {
3733
3730
  isInEditor = isInEditorEnv();
3734
3731
  if (isInEditor)
3735
- console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
3732
+ console.log("[@storm-software/eslint] Detected running in editor, some rules are disabled.");
3736
3733
  }
3737
3734
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
3738
3735
  if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
@@ -3755,10 +3752,14 @@ function getStormConfig(options, ...userConfigs) {
3755
3752
  }
3756
3753
  }
3757
3754
  const typescriptOptions = resolveSubOptions(options, "typescript");
3758
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
3755
+ let tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
3756
+ if (!tsconfigPath) {
3757
+ tsconfigPath = getTsConfigPath();
3758
+ }
3759
3759
  configs2.push(ignores(options.ignores), javascript({
3760
3760
  name,
3761
3761
  globals,
3762
+ lineEndings,
3762
3763
  isInEditor,
3763
3764
  overrides: getOverrides(options, "javascript")
3764
3765
  }), node(), jsdoc({
@@ -3786,6 +3787,7 @@ function getStormConfig(options, ...userConfigs) {
3786
3787
  if (stylisticOptions) {
3787
3788
  configs2.push(stylistic({
3788
3789
  ...stylisticOptions,
3790
+ lineEndings,
3789
3791
  lessOpinionated: options.lessOpinionated,
3790
3792
  overrides: getOverrides(options, "stylistic")
3791
3793
  }));
@@ -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,7 +1,7 @@
1
1
  import {
2
2
  banner_plugin_default
3
- } from "../chunk-JOZDGLKT.js";
4
- import "../chunk-EEGFPU3P.js";
3
+ } from "../chunk-BXVDD33Y.js";
4
+ import "../chunk-KDHZD7SF.js";
5
5
  import "../chunk-AIKLBIPC.js";
6
6
  import "../chunk-SHUYVCID.js";
7
7
  export {
@@ -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';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getFileBanner
3
- } from "../chunk-EEGFPU3P.js";
3
+ } from "../chunk-KDHZD7SF.js";
4
4
  import "../chunk-AIKLBIPC.js";
5
5
  import "../chunk-SHUYVCID.js";
6
6
  export {
@@ -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.124.3",
3
+ "version": "0.125.1",
4
4
  "type": "module",
5
5
  "description": "⚡ A package containing the base ESLint configuration used by Storm Software across many projects.",
6
6
  "repository": {