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

Implement the complete solution for processing the flat configuration structure #95

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
c4fa906
Add several internal types for config processing
daniilsapa Aug 19, 2024
f337bb9
Minor fixes for type shapes
daniilsapa Aug 19, 2024
f218215
Implement getRuleInstructions function
daniilsapa Aug 19, 2024
b335e93
Improve the error message for multiple rule options
daniilsapa Aug 19, 2024
fcabf3d
Implement a function that creates a copy of VFS for enabled rules
daniilsapa Aug 20, 2024
05f573f
Implement a function that marks files with severities
daniilsapa Aug 21, 2024
28f5a1b
Implement functions to create rule run environments
daniilsapa Aug 21, 2024
fcb72d0
Remove outdated comments
daniilsapa Aug 21, 2024
6a45789
Finish implementing functions for full-fledged config processing
daniilsapa Aug 21, 2024
3f19fe9
Fix ConfigObject type
daniilsapa Aug 22, 2024
e83032e
Connect the new config processing logic to the app
daniilsapa Aug 22, 2024
cc0e22d
Refactor function working with globs
daniilsapa Aug 22, 2024
b4bc104
Cover createVfsForRules with tests
daniilsapa Aug 22, 2024
bbe14ab
Cover markSeverities with tests
daniilsapa Aug 22, 2024
2292df6
Rearrange config files, add tests
daniilsapa Aug 23, 2024
c388fe2
Minor fixes for config processing logic, add tests
daniilsapa Aug 23, 2024
f58d889
Button up the solution
daniilsapa Aug 23, 2024
6fcbca2
Add a short explanation
daniilsapa Aug 23, 2024
51c0705
Fix tests for createRuleRunEnvironments
daniilsapa Aug 23, 2024
6c9b224
Fix issues with platform-specific path separators in tests
daniilsapa Aug 23, 2024
dea3e89
Add comments for RuleRunEnvironment
daniilsapa Aug 24, 2024
950da50
Add lodash-es, move @types/ramda to dev dependencies
daniilsapa Aug 24, 2024
5198c5d
Fix createRuleInstructions to not throw an error when options are the…
daniilsapa Aug 24, 2024
8df54d9
Handle an empty VFS edge case in createVfsForRules
daniilsapa Aug 24, 2024
304d932
Add another type of object (GlobalIgnore) inside the config and code …
daniilsapa Aug 26, 2024
3642870
Fix the misleading type name
daniilsapa Aug 26, 2024
9291379
Remove the unused type
daniilsapa Aug 26, 2024
d20c0ac
Refactor the logic determining enabled rules
daniilsapa Aug 26, 2024
a26c9cb
Change the test case description
daniilsapa Aug 26, 2024
fb72776
Make 'off' a default severity when marking FS nodes
daniilsapa Aug 26, 2024
83c067d
Finish implementing code handling GlobalIgnore object type in Config
daniilsapa Aug 27, 2024
2d64f0e
Add folders to severity maps and other severity-based structures
daniilsapa Aug 27, 2024
57b51d8
Simplify if statement
daniilsapa Aug 27, 2024
4491e7f
Refactor config model, move some excess functionality to separate mod…
daniilsapa Aug 29, 2024
492f58b
Rename getRuleSeveritySettings
daniilsapa Sep 5, 2024
a7b9d09
Rework the approach to handling GlobalIgnores
daniilsapa Sep 6, 2024
8a52e10
Refactor the solution
daniilsapa Sep 6, 2024
78ade3b
Refactor, rearrange files
daniilsapa Sep 7, 2024
7a34e43
Rename ruleRunSequence to collectDiagnostics
daniilsapa Sep 7, 2024
ba3a88d
Move removeGlobalIgnoresFromVfs to its own folder
daniilsapa Sep 7, 2024
a678205
Cover calcAndRemoveOffNodes with tests
daniilsapa Sep 7, 2024
50489e2
Refactor removeGlobalIgnoresFromVfs and cover it with tests
daniilsapa Sep 7, 2024
3cc5d2e
Rename test suffixes to spec to follow the project convention
daniilsapa Sep 7, 2024
b91baf0
Move rule options validation to the validation scheme
daniilsapa Sep 7, 2024
66aab51
Fix tests
daniilsapa Sep 7, 2024
14e6d3d
Move the rule uniqueness validation to the validation scheme
daniilsapa Sep 7, 2024
f0303da
Fix tests
daniilsapa Sep 7, 2024
065d037
Fix validation scheme
daniilsapa Sep 7, 2024
85e1e07
Implement support for relative paths in config globs
daniilsapa Sep 7, 2024
e65dd36
Add a change log
daniilsapa Sep 7, 2024
097cf61
Fix type issues with pretty-reported examples
daniilsapa Sep 7, 2024
78744ad
Fix type issues in create-rule-instructions
daniilsapa Sep 7, 2024
a59c583
Rename collectDiagnostics to runRules
daniilsapa Sep 10, 2024
1b3c6c0
Get the getRuleDescriptionUrl method back
daniilsapa Sep 10, 2024
6584028
Refactor and rename complement-diagnostics feature
daniilsapa Sep 10, 2024
4ab6520
Reduce the amount of boilerplate code with parseIntoFsdRoot
daniilsapa Sep 10, 2024
1cf35b2
Minor fixes for relative paths
daniilsapa Sep 10, 2024
d2719b0
Add a test case for relative paths
daniilsapa Sep 11, 2024
8026ca7
Rename checkToAnyFunction, add a comment
daniilsapa Sep 11, 2024
2028cea
Remove redundant /src folder
daniilsapa Sep 13, 2024
773b39f
Refactor createRuleInstructions
daniilsapa Sep 13, 2024
323751c
Refactor to convert globs for GlobalIgnore object too
daniilsapa Sep 13, 2024
bcdacfa
Set global ignores after converting globs
daniilsapa Sep 13, 2024
b06db43
Make patterns like ./src/shared/** match the containing folder itself
daniilsapa Sep 13, 2024
d4ae475
Revert "Make patterns like ./src/shared/** match the containing folde…
daniilsapa Sep 19, 2024
3a3feec
Modify the glob transformation logic to also strip trailing slashes
daniilsapa Sep 19, 2024
993c7f6
Implement the enhanced glob processing solution
daniilsapa Sep 23, 2024
2786262
Remove unused files, move markDefault to a separate file
daniilsapa Sep 23, 2024
8f8d1cc
Button up the solution
daniilsapa Sep 23, 2024
49b495b
Merge branch 'master' into feature/implement-full-config-processing
daniilsapa Sep 23, 2024
b4db89d
Fix merge conflicts
daniilsapa Sep 23, 2024
00a6b80
Refactor the solution to get the former set of features back
daniilsapa Sep 26, 2024
bc04903
Button up the solution
daniilsapa Sep 26, 2024
fe6fad3
Rename vfs-severity-wizard to vfs-severity-map
daniilsapa Sep 26, 2024
8d0d013
Implement a draft for applyExclusions
daniilsapa Sep 30, 2024
040b5a4
Refactor the logic that removes global ignores
daniilsapa Oct 2, 2024
aa1892a
Refactor features to use the new glob matching approach
daniilsapa Oct 3, 2024
ff580ee
Remove vfs-severity-map because it is no longer needed
daniilsapa Oct 3, 2024
a4dd8c3
Button up remove-global-ignores-from-vfs
daniilsapa Oct 3, 2024
44996d7
Button up the solution, remove ramda
daniilsapa Oct 3, 2024
ed62bef
Merge branch 'master' into feature/implement-full-config-processing
daniilsapa Oct 3, 2024
532a995
Fix merge conflicts
daniilsapa Oct 3, 2024
5799eee
Fix minor typecheck issues
daniilsapa Oct 3, 2024
c2a5c2e
Remove the if block from calculateFinalSeverities
daniilsapa Oct 7, 2024
0498279
Remove a useless check for rule globs presence
daniilsapa Oct 7, 2024
654eef5
Refactor the glob application logic
daniilsapa Oct 8, 2024
f31d2cd
Fix bugs in glob transformation logic
daniilsapa Oct 8, 2024
ee5c537
Fix the glob transformation logic to allow conversions for globs star…
daniilsapa Oct 8, 2024
3b4df08
Fix bugs in mergeGlobGroups
daniilsapa Oct 9, 2024
c6af74b
Fix the test case description
daniilsapa Oct 9, 2024
7c035ad
Button up the solution, remove unused files and exports
daniilsapa Oct 10, 2024
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
8 changes: 8 additions & 0 deletions .changeset/stale-brooms-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@feature-sliced/steiger-plugin': minor
'@steiger/pretty-reporter': minor
'steiger': minor
'@steiger/types': minor
---

Complete configuration parsing and application logic
6 changes: 3 additions & 3 deletions packages/pretty-reporter/src/format-single-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import figures from 'figures'
import terminalLink from 'terminal-link'
import chalk from 'chalk'

import type { AugmentedDiagnostic } from './types.js'
import type { Diagnostic } from '@steiger/types'

export function formatSingleDiagnostic(d: AugmentedDiagnostic, cwd: string): string {
export function formatSingleDiagnostic(d: Diagnostic, cwd: string): string {
const x = d.severity === 'error' ? chalk.red(figures.cross) : chalk.yellow(figures.warning)
const s = chalk.reset(figures.lineDownRight)
const bar = chalk.reset(figures.lineVertical)
Expand All @@ -23,7 +23,7 @@ ${e} ${ruleName}
`.trim()
}

function formatLocation(location: AugmentedDiagnostic['location'], cwd: string) {
function formatLocation(location: Diagnostic['location'], cwd: string) {
let path = relative(cwd, location.path)
if (location.line !== undefined) {
path += `:${location.line}`
Expand Down
8 changes: 4 additions & 4 deletions packages/pretty-reporter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import chalk from 'chalk'
import figures from 'figures'

import type { AugmentedDiagnostic } from './types.js'
import type { Diagnostic } from '@steiger/types'
import { formatSingleDiagnostic } from './format-single-diagnostic.js'
import { s } from './pluralization.js'

export function formatPretty(diagnostics: Array<AugmentedDiagnostic>, cwd: string) {
export function formatPretty(diagnostics: Array<Diagnostic>, cwd: string) {
if (diagnostics.length === 0) {
return chalk.green(`${figures.tick} No problems found!`)
}
Expand Down Expand Up @@ -43,8 +43,8 @@ export function formatPretty(diagnostics: Array<AugmentedDiagnostic>, cwd: strin
)
}

export function reportPretty(diagnostics: Array<AugmentedDiagnostic>, cwd: string) {
export function reportPretty(diagnostics: Array<Diagnostic>, cwd: string) {
console.error(formatPretty(diagnostics, cwd))
}

export type { AugmentedDiagnostic }
export type { Diagnostic }
7 changes: 0 additions & 7 deletions packages/pretty-reporter/src/types.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/_lib/prepare-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join, sep } from 'node:path'
import type { readFileSync, existsSync } from 'node:fs'
import type { FsdRoot } from '@feature-sliced/filesystem'
import type { Folder, File, Diagnostic } from '@steiger/types'
import type { Folder, File, PartialDiagnostic } from '@steiger/types'
import { vi } from 'vitest'

/** Parse a multi-line indented string with emojis for files and folders into an FSD root.
Expand Down Expand Up @@ -39,7 +39,7 @@ export function parseIntoFsdRoot(fsMarkup: string, mountTo?: string): FsdRoot {
return parseFolder(lines, mountTo ?? joinFromRoot())
}

export function compareMessages(a: Diagnostic, b: Diagnostic): number {
export function compareMessages(a: PartialDiagnostic, b: PartialDiagnostic): number {
return a.message.localeCompare(b.message) || a.location.path.localeCompare(b.location.path)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { basename, sep } from 'node:path'
import { getAllSlices, getLayers, getSegments, type LayerName } from '@feature-sliced/filesystem'
import type { Diagnostic, Folder, Rule } from '@steiger/types'
import type { PartialDiagnostic, Folder, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

/** Forbid slice names that match some segment’s name in shared (e.g., theme, i18n) */
const ambiguousSliceNames = {
name: `${NAMESPACE}/ambiguous-slice-names`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const layers = getLayers(root)
const sharedLayer = layers.shared
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/excessive-slicing/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'node:path'
import { getLayers, getSlices, isSliced } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'

import { groupSlices } from '../_lib/group-slices.js'
import { NAMESPACE } from '../constants.js'
Expand All @@ -16,7 +16,7 @@ const THRESHOLDS = {
const excessiveSlicing = {
name: `${NAMESPACE}/excessive-slicing`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const [layerName, layer] of Object.entries(getLayers(root))) {
if (!isSliced(layer) || !(layerName in THRESHOLDS)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/forbidden-imports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { layerSequence, resolveImport } from '@feature-sliced/filesystem'
import precinct from 'precinct'
const { paperwork } = precinct
import { parse as parseNearestTsConfig } from 'tsconfck'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'

import { indexSourceFiles } from '../_lib/index-source-files.js'
import { NAMESPACE } from '../constants.js'

const forbiddenImports = {
name: `${NAMESPACE}/forbidden-imports`,
async check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []
const { tsconfig } = await parseNearestTsConfig(root.path)
const sourceFileIndex = indexSourceFiles(root)

Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/import-locality/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { resolveImport } from '@feature-sliced/filesystem'
import precinct from 'precinct'
const { paperwork } = precinct
import { parse as parseNearestTsConfig } from 'tsconfck'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'

import { indexSourceFiles } from '../_lib/index-source-files.js'
import { NAMESPACE } from '../constants.js'

const importLocality = {
name: `${NAMESPACE}/import-locality`,
async check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []
const { tsconfig } = await parseNearestTsConfig(root.path)
const sourceFileIndex = indexSourceFiles(root)

Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/inconsistent-naming/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { partition } from 'lodash-es'
import pluralize from 'pluralize'
const { isPlural, plural, singular } = pluralize
import { getLayers, getSlices } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'

import { groupSlices } from '../_lib/group-slices.js'
import { NAMESPACE } from '../constants.js'
Expand All @@ -12,7 +12,7 @@ import { NAMESPACE } from '../constants.js'
const inconsistentNaming = {
name: `${NAMESPACE}/inconsistent-naming`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const { entities } = getLayers(root)
if (entities === undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/insignificant-slice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'node:fs'
import { sep, join } from 'node:path'
import { parse as parseNearestTsConfig } from 'tsconfck'
import { isSliced, resolveImport, unslicedLayers, type LayerName } from '@feature-sliced/filesystem'
import type { Folder, Diagnostic, Rule } from '@steiger/types'
import type { Folder, PartialDiagnostic, Rule } from '@steiger/types'
import precinct from 'precinct'
const { paperwork } = precinct

Expand All @@ -12,7 +12,7 @@ import { NAMESPACE } from '../constants.js'
const insignificantSlice = {
name: `${NAMESPACE}/insignificant-slice`,
async check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const references = await traceSliceReferences(root)

Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/no-file-segments/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { basename } from 'node:path'
import { getLayers, getSlices, isSliced } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const noFileSegments = {
name: `${NAMESPACE}/no-file-segments`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const layer of Object.values(getLayers(root))) {
if (!isSliced(layer)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/no-layer-public-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getIndex, getLayers } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

/** Layers that are allowed to have an index file. */
Expand All @@ -9,7 +9,7 @@ const exceptionLayers = ['app']
const noLayerPublicApi = {
name: `${NAMESPACE}/no-layer-public-api`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const [layerName, layer] of Object.entries(getLayers(root))) {
const index = getIndex(layer)
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/no-processes/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { basename } from 'node:path'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const noProcesses = {
name: `${NAMESPACE}/no-processes`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const processesLayer = root.children.find(
(child) => child.type === 'folder' && basename(child.path) === 'processes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import precinct from 'precinct'
const { paperwork } = precinct
import { parse as parseNearestTsConfig } from 'tsconfck'
import { getIndex, getLayers, getSegments, isSliced, resolveImport } from '@feature-sliced/filesystem'
import type { Folder, File, Diagnostic, Rule } from '@steiger/types'
import type { Folder, File, PartialDiagnostic, Rule } from '@steiger/types'

import { indexSourceFiles } from '../_lib/index-source-files.js'
import { NAMESPACE } from '../constants.js'
Expand All @@ -12,7 +12,7 @@ import { NAMESPACE } from '../constants.js'
const noPublicApiSidestep = {
name: `${NAMESPACE}/no-public-api-sidestep`,
async check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []
const { tsconfig } = await parseNearestTsConfig(root.path)
const sourceFileIndex = indexSourceFiles(root)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { basename } from 'node:path'
import { getAllSegments, conventionalSegmentNames } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'

import { findAllRecursively } from '../_lib/find-all-recursively.js'
import { NAMESPACE } from '../constants.js'
Expand All @@ -9,7 +9,7 @@ import { NAMESPACE } from '../constants.js'
const noReservedFolderNames = {
name: `${NAMESPACE}/no-reserved-folder-names`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const { segment } of getAllSegments(root)) {
if (segment.type === 'file') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getLayers, isSlice, isSliced } from '@feature-sliced/filesystem'
import type { Folder, Diagnostic, Rule } from '@steiger/types'
import type { Folder, PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const noSegmentlessSlices = {
name: `${NAMESPACE}/no-segmentless-slices`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const layer of Object.values(getLayers(root))) {
if (!isSliced(layer)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { basename } from 'node:path'

import { getLayers, isSliced, conventionalSegmentNames } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const noSegmentsOnSlicedLayers = {
name: `${NAMESPACE}/no-segments-on-sliced-layers`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []
const layers = Object.values(getLayers(root))

for (const layer of layers) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/no-ui-in-app/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'
import { getLayers, getSegments } from '@feature-sliced/filesystem'

const noUiInApp = {
name: `${NAMESPACE}/no-ui-in-app`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const layers = getLayers(root)

Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/public-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { join } from 'node:path'
import { getLayers, getSegments, isSliced, getIndex, getSlices } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

/** Require slices (or segments on sliceless layers) to have a public API. */
const publicApi = {
name: `${NAMESPACE}/public-api`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const [layerName, layer] of Object.entries(getLayers(root))) {
if (!isSliced(layer)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/repetitive-naming/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLayers, getSlices, isSliced } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

/**
Expand All @@ -18,7 +18,7 @@ const wordPattern = /(?:[A-Z]+|[a-z]+)[a-z]*/g
const repetitiveNaming = {
name: `${NAMESPACE}/repetitive-naming`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const layer of Object.values(getLayers(root))) {
if (!isSliced(layer)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/segments-by-purpose/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLayers, getSegments, getSlices, isSliced } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const BAD_NAMES = ['components', 'hooks', 'helpers', 'utils', 'modals', 'types', 'constants', 'consts', 'const']
Expand All @@ -8,7 +8,7 @@ const BAD_NAMES = ['components', 'hooks', 'helpers', 'utils', 'modals', 'types',
const segmentsByPurpose = {
name: `${NAMESPACE}/segments-by-purpose`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

for (const layer of Object.values(getLayers(root))) {
if (layer === null) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/shared-lib-grouping/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLayers, getSegments } from '@feature-sliced/filesystem'
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'

const THRESHOLD = 15
Expand All @@ -8,7 +8,7 @@ const THRESHOLD = 15
const sharedLibGrouping = {
name: `${NAMESPACE}/shared-lib-grouping`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

const { shared } = getLayers(root)
if (!shared) {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger-plugin-fsd/src/typo-in-layer-name/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Diagnostic, Rule } from '@steiger/types'
import type { PartialDiagnostic, Rule } from '@steiger/types'
import { NAMESPACE } from '../constants.js'
import { LayerName, layerSequence } from '@feature-sliced/filesystem'
import { distance } from 'fastest-levenshtein'
Expand All @@ -10,7 +10,7 @@ const LEVENSHTEIN_DISTANCE_UPPER_BOUND = 3
const typoInLayerName = {
name: `${NAMESPACE}/typo-in-layer-name`,
check(root) {
const diagnostics: Array<Diagnostic> = []
const diagnostics: Array<PartialDiagnostic> = []

// construct list of suggestions, like [{ input: 'shraed', suggestion: 'shared', distance: 2 }, ...],
// limit Levenshtein distance upper bound to 3,
Expand Down
Loading