-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {ESLint} from 'eslint'; | ||
|
||
export const config: ESLint.ConfigData = { | ||
plugins: ['depend'], | ||
rules: { | ||
'depend/ban-dependencies': 'error' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
export const recommended = { | ||
plugins: ['depend'], | ||
rules: {} | ||
}; | ||
import type {ESLint, Linter} from 'eslint'; | ||
|
||
export const configFactory = (plugin: ESLint.Plugin): Linter.FlatConfig => ({ | ||
plugins: { | ||
depend: plugin | ||
}, | ||
|
||
rules: { | ||
'depend/ban-dependencies': 'error' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import {recommended} from './configs/recommended.js'; | ||
import type {Rule, ESLint} from 'eslint'; | ||
import {configFactory as configRecommended} from './configs/recommended.js'; | ||
import {config as configLegacyRecommended} from './configs/legacy-recommended.js'; | ||
import {rule as banDependencies} from './rules/ban-dependencies.js'; | ||
|
||
export const configs = { | ||
recommended | ||
export const rules: Record<string, Rule.RuleModule> = { | ||
'ban-dependencies': banDependencies | ||
}; | ||
|
||
export const rules = { | ||
'ban-dependencies': banDependencies | ||
const plugin: ESLint.Plugin = {rules}; | ||
|
||
export const configs = { | ||
recommended: configLegacyRecommended, | ||
'flat/recommended': configRecommended(plugin) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type {ESLint, Linter} from 'eslint'; | ||
import * as assert from 'node:assert/strict'; | ||
import {test} from 'node:test'; | ||
import {configs} from '../main.js'; | ||
|
||
type ConfigLike = Linter.FlatConfig | ESLint.ConfigData; | ||
|
||
const isFlatConfig = (config: ConfigLike): config is Linter.FlatConfig => | ||
!Array.isArray(config.plugins); | ||
|
||
test('configs', async (t) => { | ||
await t.test('should define configs correctly', () => { | ||
assert.ok(configs['recommended']); | ||
assert.ok(configs['flat/recommended']); | ||
|
||
assert.ok(isFlatConfig(configs['flat/recommended'])); | ||
assert.equal(isFlatConfig(configs['recommended']), false); | ||
}); | ||
}); |