Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions demo/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function someFunc({ prop1 }) {
console.log({ prop1 })
}

export function someFunc2(prop1): void {}

const unusedVar = 3

type UnusedType = number
4 changes: 4 additions & 0 deletions demo/test/linting-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ test('Should apply our custom linting rules consistently', async (t) => {
test('Should apply a consistent overall eslint configuration', async (t) => {
return processFile(t, 'local-linting-final-config.json') // If this fails, go cry to mommy
})

test('Should apply a consistent overall eslint configuration for TS', async (t) => {
return processFile(t, 'local-linting-final-config-ts.json') // If this fails, go cry to mommy
})
41 changes: 27 additions & 14 deletions demo/test/snapshots/format-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,38 @@
/* eslint no-console: "off" -- node scripts use the console, so disable for the whole file */

const FS = require('fs')
const finalConfig = require('./local-linting-final-config.json')
const finalJsConfig = require('./local-linting-final-config.json')
const finalTsConfig = require('./local-linting-final-config-ts.json')

const formattedRules = Object.fromEntries(
Object.entries(finalConfig?.rules ?? {}).sort(([ruleNameA], [ruleNameB]) => {
if (ruleNameA > ruleNameB) return 1
if (ruleNameB > ruleNameA) return -1
return 0
})
const parseConfig = (config) => {
return {
...config,
rules: Object.fromEntries(
Object.entries(config?.rules ?? {}).sort(([ruleNameA], [ruleNameB]) => {
if (ruleNameA > ruleNameB) return 1
if (ruleNameB > ruleNameA) return -1
return 0
})
),
parser: config?.parser?.split('node_modules')[1],
}
}

const finalJsConfigName = 'local-linting-final-config'
FS.writeFile(
`./demo/test/snapshots/${finalJsConfigName}.json`,
JSON.stringify(parseConfig(finalJsConfig), null, 2),
(err) => {
if (err) console.log(`There was an error writing to ${finalJsConfigName}.json file:`, err)
}
)

const finalTsConfigName = 'local-linting-final-config-ts'
FS.writeFile(
'./demo/test/snapshots/local-linting-final-config.json',
JSON.stringify(
{ ...finalConfig, rules: formattedRules, parser: finalConfig.parser?.split('eslint-config-tree')[1] },
null,
2
),
`./demo/test/snapshots/${finalTsConfigName}.json`,
JSON.stringify(parseConfig(finalTsConfig), null, 2),
(err) => {
if (err) console.log('There was an error writing to local-linting-final-config.json file:', err)
if (err) console.log(`There was an error writing to ${finalTsConfigName}.json file:`, err)
}
)

Expand Down
Loading