Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'eslint-config-airbnb-base' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
// Disable rules for which there are eslint-plugin-babel replacements:
// https://github.com/babel/eslint-plugin-babel#rules
'new-cap': 'off',
'no-invalid-this': 'off',
'object-curly-spacing': 'off',
semi: 'off',
'no-unused-expressions': 'off',
// Ensure the replacement rules use the options set by airbnb rather than ESLint defaults.
'babel/new-cap': airbnbBaseStyle['new-cap'],
'babel/no-invalid-this': airbnbBaseBestPractices['no-invalid-this'],
'babel/object-curly-spacing': airbnbBaseStyle['object-curly-spacing'],
'babel/semi': airbnbBaseStyle.semi,
'babel/no-unused-expressions':
airbnbBaseBestPractices['no-unused-expressions'],
'class-methods-use-this': 'off',
'no-shadow': 'off',
'no-underscore-dangle': 'off',
'prettier/prettier': [
'error',
{
singleQuote: true,
jsxBracketSameLine: true,
trailingComma: 'all',
proseWrap: 'always',
endOfLine: 'lf',
},
],
},
// Override AirBnB's configuration of 'always', since they only set that value due to
// babel-preset-airbnb not supporting class properties, whereas @neutrinojs/react does.
'react/state-in-constructor': ['error', 'never'],
// Disable rules for which there are eslint-plugin-babel replacements:
// https://github.com/babel/eslint-plugin-babel#rules
'new-cap': 'off',
'no-invalid-this': 'off',
'object-curly-spacing': 'off',
semi: 'off',
'no-unused-expressions': 'off',
// Ensure the replacement rules use the options set by airbnb rather than ESLint defaults.
'babel/new-cap': airbnbBaseStyle['new-cap'],
'babel/no-invalid-this': airbnbBaseBestPractices['no-invalid-this'],
'babel/object-curly-spacing':
airbnbBaseStyle['object-curly-spacing'],
'babel/semi': airbnbBaseStyle.semi,
'babel/no-unused-expressions':
airbnbBaseBestPractices['no-unused-expressions'],
...baseConfig.rules,
},
},
},
}),
);
};
'@typescript-eslint/no-use-before-define': baseVariablesRules['no-use-before-define'],
// Replace Airbnb 'no-useless-constructor' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': baseES6Rules['no-useless-constructor'],
// Replace Airbnb 'quotes' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
quotes: 'off',
'@typescript-eslint/quotes': baseStyleRules.quotes,
// Replace Airbnb 'semi' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
semi: 'off',
'@typescript-eslint/semi': baseStyleRules.semi,
// Append 'ts' and 'tsx' to Airbnb 'import/extensions' rule
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': [
baseImportsRules['import/extensions'][0],
baseImportsRules['import/extensions'][1],
{
...baseImportsRules['import/extensions'][2],
ts: 'never',
tsx: 'never',
},
],
// Append 'ts' and 'tsx' extensions to Airbnb 'import/no-extraneous-dependencies' rule
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
'import/no-extraneous-dependencies': [
...(baseConfig.extends || []),
],
rules: {
// Disable rules for which there are eslint-plugin-babel replacements:
// https://github.com/babel/eslint-plugin-babel#rules
'new-cap': 'off',
'no-invalid-this': 'off',
'object-curly-spacing': 'off',
semi: 'off',
'no-unused-expressions': 'off',
// Ensure the replacement rules use the options set by airbnb-base rather than ESLint defaults.
'babel/new-cap': airbnbBaseStyle['new-cap'],
'babel/no-invalid-this': airbnbBaseBestPractices['no-invalid-this'],
'babel/object-curly-spacing':
airbnbBaseStyle['object-curly-spacing'],
'babel/semi': airbnbBaseStyle.semi,
'babel/no-unused-expressions':
airbnbBaseBestPractices['no-unused-expressions'],
...baseConfig.rules,
},
},
},
}),
);
};
'use strict';
const { createAliases, tsconfigResolver } = require('@tunnckocore/utils');
const airbnbBase = require('eslint-config-airbnb-base');
const { alias, workspaces } = createAliases();
// eslint-disable-next-line import/no-dynamic-require
const bestPractices = require(airbnbBase.extends[0]);
const ignoredProps = bestPractices.rules[
'no-param-reassign'
][1].ignorePropertyModificationsFor.concat(
'err',
'x',
'_',
'opts',
'options',
'settings',
'config',
'cfg',
);
const unicornRules = {
// It is too much annoyance for me. It's a good thing, but generally
const assign = require('object.assign');
const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules;
const dangleRules = baseStyleRules['no-underscore-dangle'];
module.exports = {
plugins: [
'react',
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
// View link below for react rules documentation
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
extensions: ['.mjs', '.js', '.ts', '.json'],
},
},
// Append 'ts' extensions to Airbnb 'import/extensions' setting
'import/extensions': ['.js', '.ts', '.mjs'],
},
rules: {
// Replace Airbnb 'brace-style' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
'brace-style': 'off',
'@typescript-eslint/brace-style': baseStyleRules['brace-style'],
// Replace Airbnb 'camelcase' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md
camelcase: 'off',
'@typescript-eslint/camelcase': baseStyleRules.camelcase,
// Replace Airbnb 'func-call-spacing' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': baseStyleRules['func-call-spacing'],
// Replace Airbnb 'indent' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
indent: 'off',
'@typescript-eslint/indent': baseStyleRules.indent,
// Replace Airbnb 'no-array-constructor' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'],
'@typescript-eslint/brace-style': baseStyleRules['brace-style'],
// Replace Airbnb 'camelcase' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md
camelcase: 'off',
'@typescript-eslint/camelcase': baseStyleRules.camelcase,
// Replace Airbnb 'func-call-spacing' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': baseStyleRules['func-call-spacing'],
// Replace Airbnb 'indent' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
indent: 'off',
'@typescript-eslint/indent': baseStyleRules.indent,
// Replace Airbnb 'no-array-constructor' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'],
// Replace Airbnb 'no-empty-function' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': baseBestPracticesRules['no-empty-function'],
// Replace Airbnb 'no-extra-parens' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': baseErrorsRules['no-extra-parens'],
'@typescript-eslint/no-unused-vars': baseVariablesRules['no-unused-vars'],
// Replace Airbnb 'no-use-before-define' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': baseVariablesRules['no-use-before-define'],
// Replace Airbnb 'no-useless-constructor' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': baseES6Rules['no-useless-constructor'],
// Replace Airbnb 'quotes' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
quotes: 'off',
'@typescript-eslint/quotes': baseStyleRules.quotes,
// Replace Airbnb 'semi' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
semi: 'off',
'@typescript-eslint/semi': baseStyleRules.semi,
// Append 'ts' and 'tsx' to Airbnb 'import/extensions' rule
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': [
baseImportsRules['import/extensions'][0],
baseImportsRules['import/extensions'][1],
{
...baseImportsRules['import/extensions'][2],
ts: 'never',
tsx: 'never',
},