Skip to content

Commit

Permalink
experimental.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanb committed Jul 23, 2024
1 parent 3c76d33 commit 46e11da
Show file tree
Hide file tree
Showing 50 changed files with 4,199 additions and 1,119 deletions.
145 changes: 145 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import promisePlugin from 'eslint-plugin-promise'
import reactPlugin from 'eslint-plugin-react'
import stylistic from '@stylistic/eslint-plugin'
import nodePlugin from 'eslint-plugin-n'
import globals from 'globals'

/**
* Packages within the monorepo (that can be imported)
*/
const monoRepoPackages = [
'@iwsio/json-csv-core',
'@iwsio/json-csv-node'
]

/**
* These project paths are node specific projects and require the package
* names above to be included in the n/no-extraneous-import rule.
*/
const monoRepoNodeProjects = [
'packages/json-csv-core',
'packages/json-csv-node'
]

/**
* And here's the actual configuration.
*/
export default [
...tseslint.config(

// global ignores have a single prop `ignores`
{
ignores: ['**/node_modules/*', '**/dist/'] // global ignore with single ignore key
},

// applies to all files: Core ES Rules
eslint.configs.recommended,

// applies to all files: Core TS Rules
...tseslint.configs.recommended,

/**
* Stylistic rules factory. This generates styling rules with a few options.
* For details, see: https://eslint.style/guide/config-presets#configuration-factory
* For options, see: https://github.com/eslint-stylistic/eslint-stylistic/blob/main/packages/eslint-plugin/configs/customize.ts
**/
stylistic.configs.customize({
braceStyle: '1tbs',
commaDangle: 'never',
indent: 'tab',
jsx: true,
quotes: 'single',
semi: false
}),
/**
* Applies to all files: Additional plugins like: promise, stylistic, and react
*/
{
plugins: {
promise: promisePlugin,
react: reactPlugin
},
languageOptions: {
ecmaVersion: 2023, // Targeted ES

/**
* Global variables to consider; we're just including all browser, node,
* and es2023 ones. (like window, document, process, etc)
*/
globals: {
...globals.browser,
...globals.node,
...globals.es2023,
...{
describe: false,
it: false,
before: false,
after: false,
beforeEach: false,
afterEach: false,
test: false,
expect: false,
should: false
}
}
},

/**
* Rules configuration; we start with the recommended and then follow with overrides.
*/
rules: {
...promisePlugin.configs.recommended.rules,
...reactPlugin.configs.recommended.rules,
...reactPlugin.configs['jsx-runtime'].rules,

'n/no-unsupported-features/es-syntax': 'off', // We're mixing ESM and CJS with controls around the Node 10 runtime.


// Overrides and additions
'promise/always-return': ['error', { ignoreLastCallback: true }],

// enable underscore ignore pattern for unused vars
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}]
},

settings: {
react: {
version: 'detect' // You can add this if you get a warning about the React version when you lint
}
}
},

{
files: ['**/*.(test|spec).(mj|j|t|cj|ct|mt)s', '**/test-runner/**/*', '**/test-runner-core/**/*'],
rules: {
'@stylistic/max-statements-per-line': ['error', { max: 2 }],
'@typescript-eslint/no-var-requires': 'off'
}
},

// applies to only Node project files referenced above.
{
// Node rules
files: monoRepoNodeProjects.map(path => `${path}/**/*`),

plugins: {
n: nodePlugin
},

rules: {
...nodePlugin.configs['flat/recommended'].rules,

'n/no-extraneous-import': ['error', {
allowModules: [...monoRepoPackages]
}]
}
}
)
]
2 changes: 1 addition & 1 deletion npm-version-helper.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ function gatherVerisonAndEmit(node, script, arg0) {
process.stdout.write(projVersion, 'utf8')
}

gatherVerisonAndEmit(...process.argv)
gatherVerisonAndEmit(...process.argv)
Loading

0 comments on commit 46e11da

Please sign in to comment.