chore: dev env linting...

This commit is contained in:
Bill Church 2024-12-14 13:49:41 +00:00
parent c802350442
commit 8e84f32f5a
No known key found for this signature in database

View file

@ -1,87 +1,85 @@
import eslint from '@eslint/js'; import eslint from '@eslint/js'
import nodePlugin from 'eslint-plugin-node'; import nodePlugin from 'eslint-plugin-node'
import securityPlugin from 'eslint-plugin-security'; import securityPlugin from 'eslint-plugin-security'
import prettierPlugin from 'eslint-plugin-prettier'; import prettierPlugin from 'eslint-plugin-prettier'
export default [ export default [
eslint.configs.recommended, eslint.configs.recommended,
{ {
ignores: ['**/*{.,-}min.js'], ignores: ['**/*{.,-}min.js'],
languageOptions: { languageOptions: {
ecmaVersion: 2024, ecmaVersion: 2024,
sourceType: 'module', sourceType: 'module',
parserOptions: { parserOptions: {
ecmaFeatures: { ecmaFeatures: {
impliedStrict: true impliedStrict: true,
}
},
globals: {
...nodePlugin.configs.recommended.globals,
}
}, },
plugins: { },
node: nodePlugin, globals: {
security: securityPlugin, ...nodePlugin.configs.recommended.globals,
prettier: prettierPlugin },
},
rules: {
// Modern JavaScript
'no-var': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'template-curly-spacing': ['error', 'never'],
// Node.js specific rules
// 'node/exports-style': ['error', 'exports'],
'node/file-extension-in-import': ['error', 'always'],
'node/prefer-global/buffer': ['error', 'always'],
'node/prefer-global/console': ['error', 'always'],
'node/prefer-global/process': ['error', 'always'],
'node/prefer-global/url-search-params': ['error', 'always'],
'node/prefer-global/url': ['error', 'always'],
'node/prefer-promises/dns': 'error',
'node/prefer-promises/fs': 'error',
// Security rules
'security/detect-buffer-noassert': 'error',
'security/detect-child-process': 'warn',
'security/detect-disable-mustache-escape': 'error',
'security/detect-eval-with-expression': 'error',
'security/detect-new-buffer': 'error',
'security/detect-no-csrf-before-method-override': 'error',
'security/detect-non-literal-fs-filename': 'warn',
'security/detect-non-literal-regexp': 'warn',
'security/detect-non-literal-require': 'warn',
'security/detect-object-injection': 'warn',
'security/detect-possible-timing-attacks': 'warn',
'security/detect-pseudoRandomBytes': 'warn',
// Best practices and style
'no-console': ['warn', { allow: ['warn', 'error', 'info', 'debug'] }],
'curly': ['error', 'all'],
'eqeqeq': ['error', 'always', { null: 'ignore' }],
'no-return-await': 'error',
'require-await': 'error',
'prettier/prettier': ['error', {
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
semi: false
}]
}
}, },
{ plugins: {
files: ['**/*.test.js', '**/*.spec.js'], node: nodePlugin,
languageOptions: { security: securityPlugin,
globals: { prettier: prettierPlugin,
jest: true },
} rules: {
// Modern JavaScript
'no-var': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'template-curly-spacing': ['error', 'never'],
// Node.js specific rules
// 'node/exports-style': ['error', 'exports'],
'node/file-extension-in-import': ['error', 'always'],
// 'node/prefer-global/buffer': ['error', 'always'],
// 'node/prefer-global/console': ['error', 'always'],
// 'node/prefer-global/process': ['error', 'always'],
// 'node/prefer-global/url-search-params': ['error', 'always'],
// 'node/prefer-global/url': ['error', 'always'],
// 'node/prefer-promises/dns': 'error',
// 'node/prefer-promises/fs': 'error',
// Security rules
'security/detect-buffer-noassert': 'error',
'security/detect-child-process': 'warn',
'security/detect-disable-mustache-escape': 'error',
'security/detect-eval-with-expression': 'error',
'security/detect-new-buffer': 'error',
'security/detect-no-csrf-before-method-override': 'error',
'security/detect-non-literal-fs-filename': 'warn',
'security/detect-non-literal-regexp': 'warn',
'security/detect-non-literal-require': 'warn',
'security/detect-object-injection': 'warn',
'security/detect-possible-timing-attacks': 'warn',
'security/detect-pseudoRandomBytes': 'warn',
// Best practices and style
'no-console': ['warn', { allow: ['warn', 'error', 'info', 'debug'] }],
curly: ['error', 'all'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-return-await': 'error',
'require-await': 'error',
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
semi: false,
}, },
rules: { ],
'node/no-unpublished-require': 'off', },
'node/no-missing-require': 'off' },
} {
} files: ['**/*.test.js', '**/*.spec.js'],
]; rules: {
'node/no-unpublished-require': 'off',
'node/no-missing-require': 'off',
},
},
]