Skip to content

Commit

Permalink
updo, @eslint/json (not in main config yet) and vitest allowed reach
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Oct 14, 2024
1 parent 72389a5 commit 43190f5
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 137 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@xylabs/ts-scripts-yarn3": "workspace:^"
},
"devDependencies": {
"@eslint/json": "^0.5.0",
"@types/json-schema": "^7.0.15",
"@types/node": "^22.7.5",
"@xylabs/eslint-config-flat": "workspace:^",
Expand All @@ -54,7 +55,7 @@
"eslint-import-resolver-typescript": "^3.6.3",
"rimraf": "^6.0.1",
"typescript": "^5.6.3",
"vitest": "^2.1.2"
"vitest": "^2.1.3"
},
"peerDependencies": {
"typescript": "^5"
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-config-flat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@
"package-compile2": "yarn tsc -p tsconfig.json --module es2022 --outDir dist --rootDir src"
},
"dependencies": {
"@eslint/json": "^0.5.0",
"@stylistic/eslint-plugin": "^2.9.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"eslint": "^9.12.0",
"eslint-plugin-depend": "^0.11.0",
"eslint-plugin-import-x": "^4.3.1",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-md": "^1.0.19",
"eslint-plugin-package-json": "^0.15.3",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-sonarjs": "^2.0.3",
"eslint-plugin-unicorn": "^56.0.0",
"eslint-plugin-workspaces": "^0.10.1",
"jsonc-eslint-parser": "^2.4.0"
"eslint-plugin-workspaces": "^0.10.1"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-flat/src/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const importConfig: Linter.Config = {
'warn',
{
allow: [
'vitest/*', // Allow imports from vitest
'@*/**', // Allow imports from any @scoped package
// Allow imports to any index.js file
'**/index.js',
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-flat/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Linter } from 'eslint'

import { importConfig } from './import/index.ts'
// import { jsonConfig } from './json/index.ts'
// import { markdownConfig } from './markdown/index.ts'
// import { prettierConfig } from './prettier/index.ts'
import { rulesConfig } from './rules/index.ts'
Expand All @@ -13,16 +12,18 @@ import { workspacesConfig } from './workspaces/index.ts'
export const config: Linter.Config[] = [
// markdownConfig,
typescriptConfig,
// jsonConfig,
unicornConfig,
workspacesConfig,
rulesConfig,
// prettierConfig,
importConfig,
// sonarConfig,
// sonarConfig
]

export { importConfig } from './import/index.ts'
export {
json5Config, jsoncConfig, jsonConfig,
} from './json/index.ts'
export { rulesConfig } from './rules/index.ts'
export { sonarConfig } from './sonar/index.ts'
export { ignores, typescriptConfig } from './typescript/index.ts'
Expand Down
47 changes: 18 additions & 29 deletions packages/eslint-config-flat/src/json/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
import json from '@eslint/json'
import type { ESLint, Linter } from 'eslint'
import jsonc from 'eslint-plugin-jsonc'
import jsoncParser from 'jsonc-eslint-parser'

export const jsonConfig: Linter.FlatConfig = {
ignores: ['.yarn/**', 'jest.config.cjs', '**/dist/**', 'dist', 'build/**', 'node_modules/**'],
files: ['**/*.json', '**/*.jsonc', '**/*.json5'],
plugins: { jsonc: jsonc as unknown as ESLint.Plugin },
languageOptions: { parser: jsoncParser },
rules: {
...jsonc.configs['all'].rules,

/// Support arrays with and without new lines but they can't mix
'jsonc/array-element-newline': ['error', 'consistent'],

'jsonc/auto': 'off',

/// see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/comma-dangle.html
'jsonc/comma-dangle': ['error', 'only-multiline'],

/// Indent with 2 spaces
'jsonc/indent': ['error', 2, {}],

/// Not all keys are camelCase
'jsonc/key-name-casing': 'off',
export const jsonConfig: Linter.Config = {
files: ['**/*.json'],
plugins: { json: json as unknown as ESLint.Plugin },
language: 'json/json',
rules: { 'json/no-duplicate-keys': ['error'] },
}

/// jsonc and json5 can have comments
'jsonc/no-comments': 'off',
export const jsoncConfig: Linter.Config = {
files: ['**/*.jsonc'],
plugins: { json: json as unknown as ESLint.Plugin },
language: 'json/jsonc',
rules: { 'json/no-duplicate-keys': ['error'] },
}

/// Don't sort keys. We want to keep the order of keys as they are:
/// especially in arrays.
'jsonc/sort-keys': 'off',
},
export const json5Config: Linter.Config = {
files: ['**/*.json5'],
plugins: { json: json as unknown as ESLint.Plugin },
language: 'json/json5',
rules: { 'json/no-duplicate-keys': ['error'] },
}
2 changes: 1 addition & 1 deletion packages/ts-scripts-yarn3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"tsup": "^8.3.0",
"typedoc": "^0.26.9",
"types-package-json": "^2.0.39",
"vitest": "^2.1.2",
"vitest": "^2.1.3",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dotenv from 'dotenv'
// eslint-disable-next-line import-x/no-internal-modules
import { defineConfig } from 'vitest/config'

dotenv.config()
Expand Down
2 changes: 1 addition & 1 deletion vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineWorkspace } from 'vitest/config'

export default defineWorkspace([
"./vitest.config.ts"
'./vitest.config.ts',
])
Loading

0 comments on commit 43190f5

Please sign in to comment.