Skip to content

Commit

Permalink
Updated dependencies, updated node config and react config
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed May 16, 2023
1 parent 006e2fc commit c0baeb7
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 244 deletions.
104 changes: 52 additions & 52 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
{
"MD001": true,
"MD003": {
"style": "atx"
},
"MD004": {
"style": "sublist"
},
"MD005": true,
"MD007": true,
"MD010": true,
"MD011": true,
"MD012": true,
"MD013": false,
"MD018": true,
"MD019": true,
"MD022": true,
"MD023": true,
"MD024": {
"siblings_only": true
},
"MD025": true,
"MD026": true,
"MD027": true,
"MD028": true,
"MD029": true,
"MD030": true,
"MD031": true,
"MD032": true,
"MD033": {
"allowed_elements": [
"table", "thead", "tbody", "tr", "th", "td",
"style", "code", "b", "i", "u", "br"
]
},
"MD034": true,
"MD035": true,
"MD036": true,
"MD037": true,
"MD038": true,
"MD039": true,
"MD040": true,
"MD041": true,
"MD042": true,
"MD045": true,
"MD046 ": {
"style": "fenced"
},
"MD047": true,
"MD048 ": {
"style": "backtick"
}
}
"MD001": true,
"MD003": {
"style": "atx"
},
"MD004": {
"style": "sublist"
},
"MD005": true,
"MD007": true,
"MD010": true,
"MD011": true,
"MD012": true,
"MD013": false,
"MD018": true,
"MD019": true,
"MD022": true,
"MD023": true,
"MD024": {
"siblings_only": true
},
"MD025": true,
"MD026": true,
"MD027": true,
"MD028": true,
"MD029": true,
"MD030": true,
"MD031": true,
"MD032": true,
"MD033": {
"allowed_elements": [
"table", "thead", "tbody", "tr", "th", "td",
"style", "code", "b", "i", "u", "br"
]
},
"MD034": true,
"MD035": true,
"MD036": true,
"MD037": true,
"MD038": true,
"MD039": true,
"MD040": true,
"MD041": true,
"MD042": true,
"MD045": true,
"MD046 ": {
"style": "fenced"
},
"MD047": true,
"MD048 ": {
"style": "backtick"
}
}
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/.eslintrc.txt
/eslint.config.js
/tests
/import-types.d.ts
/docs
/*.md
/tsconfig.json
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
![npm next version](https://img.shields.io/npm/v/@dtrw/eslint-config/next)
![NPM License](https://img.shields.io/npm/l/@dtrw/eslint-config)
![Release](https://img.shields.io/github/actions/workflow/status/burtek/eslint-config/make-release.yml?label=publish%20release)
![dependencies](https://img.shields.io/librariesio/release/npm/@dtrw/eslint-config)


This is repository with my `eslint` configs for multiple purposes that are used (or will be used) in my other projects.

## WARNING

This README is outdated, please wait for 2.0.0 docs.

## Install

```bash
Expand Down
48 changes: 29 additions & 19 deletions configs/node.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { defineFlatConfig } from 'eslint-define-config';
import n from 'eslint-plugin-n';
import nModule from 'eslint-plugin-n/configs/recommended-module.js';
import nScript from 'eslint-plugin-n/configs/recommended-script.js';
import nodeSecurity from 'eslint-plugin-security-node';
import globals from 'globals';


export function prepareConfig() {
/**
* @param {Object} [config]
* @param {'module' | 'script'} [config.mode]
*/
export function prepareConfig({ mode = 'module' } = {}) {
const isModule = mode === 'module';

return defineFlatConfig([
{
files: [isModule ? '**/*.{cjs,cts}' : '**/*.{js,cjs,ts,cts}'],
...nScript
},
{
files: [isModule ? '**/*.{js,mjs,ts,mts}' : '**/*.{mjs,mts}'],
...nModule
},
{
files: ['**/*.{js,cjs,mjs,ts,cts,mts}'],
plugins: {
n,
'security-node': nodeSecurity
},
languageOptions: {
globals: {
// eslint-disable-next-line no-warning-comments
...n.configs['recommended-module'].globals, // TODO: recommended once eslint-plugin-n moves to FlatConfig
...globals.node
},
globals: { ...globals.node },
parserOptions: { ecmaFeatures: { globalReturn: false } }
},
rules: {
// eslint-disable-next-line no-warning-comments
...n.configs['recommended-module'].rules, // TODO: recommended once eslint-plugin-n moves to FlatConfig
...nodeSecurity.configs.recommended.rules,

'no-console': 'off',

'n/no-missing-import': 'off',
Expand All @@ -37,10 +40,7 @@ export function prepareConfig() {
'n/prefer-global/url-search-params': 'error',
'n/prefer-global/url': 'error',
'n/prefer-promises/dns': 'error',
'n/prefer-promises/fs': 'error',

// https://github.com/gkouziik/eslint-plugin-security-node/pull/63
'security-node/detect-unhandled-async-errors': 'off'
'n/prefer-promises/fs': 'error'
}
},
{
Expand All @@ -50,6 +50,16 @@ export function prepareConfig() {
'n/no-unpublished-require': 'error',
'n/no-unsupported-features/es-syntax': 'off'
}
},
{
files: ['**/*.{js,cjs,mjs,ts,cts,mts}'],
plugins: { 'security-node': nodeSecurity },
rules: {
...nodeSecurity.configs.recommended.rules,

// https://github.com/gkouziik/eslint-plugin-security-node/pull/63
'security-node/detect-unhandled-async-errors': 'off'
}
}
]);
}
8 changes: 6 additions & 2 deletions configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function prepareConfig({ a11y = false, nextjs = false } = {}) {
'jsx-quotes': ['error', 'prefer-double'],

'react/button-has-type': 'warn',
'react/hook-use-state': 'error',
'react/hook-use-state': ['error', { allowDestructuredState: true }],
'react/iframe-missing-sandbox': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-child-element-spacing': 'error',
Expand Down Expand Up @@ -121,6 +121,7 @@ export function prepareConfig({ a11y = false, nextjs = false } = {}) {
'react/no-danger': 'error',
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
'react/no-object-type-as-default-prop': 'error',
'react/no-redundant-should-component-update': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
Expand Down Expand Up @@ -158,7 +159,10 @@ export function prepareConfig({ a11y = false, nextjs = false } = {}) {
{
files: jsxFiles,
plugins: { 'jsx-a11y': jsxA11y },
rules: { ...jsxA11y.configs.recommended.rules }
rules: {
...jsxA11y.configs.recommended.rules,
'jsx-a11y/anchor-ambiguous-text': 'error'
}
}
]);

Expand Down
Loading

0 comments on commit c0baeb7

Please sign in to comment.