Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2025
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
  2. import stylistic from '@stylistic/eslint-plugin'
  3.  
  4. export default createConfigForNuxt(
  5.   {
  6.     features: {
  7.       stylistic: true,
  8.     },
  9.   })
  10.   .append(
  11.     stylistic.configs['recommended-flat'],
  12.     {
  13.       files: ['**/*.js', '**/*.ts', '**/*.vue'],
  14.       plugins: {
  15.         '@stylistic': stylistic,
  16.       },
  17.       rules: {
  18.         'vue/array-element-newline': ['error', 'consistent'],
  19.  
  20.         // https://eslint.style/rules/default/array-bracket-newline
  21.         '@stylistic/array-bracket-newline': ['error', 'consistent'],
  22.  
  23.         // https://eslint.style/rules/default/array-bracket-spacing
  24.         '@stylistic/array-bracket-spacing': ['error', 'never'],
  25.  
  26.         // https://eslint.style/rules/default/array-element-newline
  27.         '@stylistic/array-element-newline': ['error', 'consistent'],
  28.  
  29.         // require parens in arrow function arguments
  30.         // https://eslint.style/rules/default/arrow-parens
  31.         '@stylistic/arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
  32.  
  33.         // require space before/after arrow function's arrow
  34.         // https://eslint.style/rules/default/arrow-spacing
  35.         '@stylistic/arrow-spacing': ['error', {
  36.           after: true,
  37.           before: true,
  38.         }],
  39.  
  40.         // https://eslint.style/rules/default/block-spacing
  41.         '@stylistic/block-spacing': ['error', 'always'],
  42.  
  43.         // enforce one true brace style
  44.         '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
  45.  
  46.         // require trailing commas in multiline object literals
  47.         '@stylistic/comma-dangle': ['error', {
  48.           arrays: 'always-multiline',
  49.           exports: 'always-multiline',
  50.           functions: 'always-multiline',
  51.           imports: 'always-multiline',
  52.           objects: 'always-multiline',
  53.         }],
  54.  
  55.         // enforce spacing before and after comma
  56.         '@stylistic/comma-spacing': ['error', {
  57.           after: true,
  58.           before: false,
  59.         }],
  60.  
  61.         // enforce one true comma style
  62.         '@stylistic/comma-style': ['error', 'last', {
  63.           exceptions: {
  64.             ArrayExpression: false,
  65.             ArrayPattern: false,
  66.             ArrowFunctionExpression: false,
  67.             CallExpression: false,
  68.             FunctionDeclaration: false,
  69.             FunctionExpression: false,
  70.             ImportDeclaration: false,
  71.             NewExpression: false,
  72.             ObjectExpression: false,
  73.             ObjectPattern: false,
  74.             VariableDeclaration: false,
  75.           },
  76.         }],
  77.  
  78.         // disallow padding inside computed properties
  79.         '@stylistic/computed-property-spacing': ['error', 'never'],
  80.  
  81.         // https://eslint.style/rules/default/dot-location
  82.         '@stylistic/dot-location': ['error', 'property'],
  83.  
  84.         // enforce newline at the end of file, with no multiple empty lines
  85.         '@stylistic/eol-last': ['error', 'always'],
  86.  
  87.         // enforce spacing between functions and their invocations
  88.         // https://eslint.style/rules/default/func-call-spacing
  89.         '@stylistic/func-call-spacing': ['error', 'never'],
  90.  
  91.         // https://eslint.style/rules/default/function-call-argument-newline
  92.         '@stylistic/function-call-argument-newline': ['error', 'consistent'],
  93.  
  94.         // enforce consistent line breaks inside function parentheses
  95.         // https://eslint.style/rules/default/function-paren-newline
  96.         '@stylistic/function-paren-newline': ['error', 'consistent'],
  97.  
  98.         // enforce the spacing around the * in generator functions
  99.         // https://eslint.style/rules/default/generator-star-spacing
  100.         '@stylistic/generator-star-spacing': ['error', {
  101.           after: true,
  102.           before: false,
  103.         }],
  104.  
  105.         // Enforce the location of arrow function bodies with implicit returns
  106.         // https://eslint.style/rules/default/implicit-arrow-linebreak
  107.         '@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
  108.  
  109.         // enforces spacing between keys and values in object literal properties
  110.         '@stylistic/key-spacing': ['error', {
  111.           afterColon: true,
  112.           beforeColon: false,
  113.         }],
  114.  
  115.         // require a space before & after certain keywords
  116.         '@stylistic/keyword-spacing': ['error', {
  117.           after: true,
  118.           before: true,
  119.           overrides: {
  120.             case: { after: true },
  121.             return: { after: true },
  122.             throw: { after: true },
  123.           },
  124.         }],
  125.  
  126.         // enforce consistent 'LF' or 'CRLF' as linebreaks
  127.         // https://eslint.style/rules/default/linebreak-style
  128.         '@stylistic/linebreak-style': ['error', 'unix'],
  129.  
  130.         // enforces empty lines around comments
  131.         '@stylistic/lines-around-comment': ['error', {
  132.           beforeBlockComment: true,
  133.  
  134.           /**
  135.           * Want to be able to add comments below code
  136.           *
  137.           * For example:
  138.           * sum(1, 1)
  139.           * // => 2
  140.           */
  141.           beforeLineComment: false,
  142.           afterHashbangComment: true,
  143.  
  144.           allowBlockStart: true,
  145.           allowObjectStart: true,
  146.           allowArrayStart: true,
  147.           allowClassStart: true,
  148.         }],
  149.  
  150.         // require or disallow an empty line between class members
  151.         // https://eslint.style/rules/default/lines-between-class-members
  152.         '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
  153.  
  154.         // https://eslint.style/rules/default/max-statements-per-line
  155.         '@stylistic/max-statements-per-line': ['warn', { max: 1 }],
  156.  
  157.         // https://eslint.style/rules/default/multiline-ternary
  158.         '@stylistic/multiline-ternary': ['error', 'always-multiline'],
  159.  
  160.         // disallow the omission of parentheses when invoking a constructor with no arguments
  161.         // https://eslint.style/rules/default/new-parens
  162.         '@stylistic/new-parens': 'error',
  163.  
  164.         // enforces new line after each method call in the chain to make it
  165.         // more readable and easy to maintain
  166.         // https://eslint.style/rules/default/newline-per-chained-call
  167.         '@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
  168.  
  169.         // disallow arrow functions where they could be confused with comparisons
  170.         // https://eslint.style/rules/default/no-confusing-arrow
  171.         '@stylistic/no-confusing-arrow': ['error', {
  172.           allowParens: true,
  173.         }],
  174.  
  175.         // disallow unnecessary parentheses
  176.         // https://eslint.style/rules/default/no-extra-parens
  177.         '@stylistic/no-extra-parens': ['off', 'all', {
  178.           conditionalAssign: true,
  179.  
  180.           // delegate to eslint-plugin-react
  181.           enforceForArrowConditionals: false,
  182.           ignoreJSX: 'all',
  183.           nestedBinaryExpressions: false,
  184.           returnAssign: false,
  185.         }],
  186.  
  187.         // disallow unnecessary semicolons
  188.         '@stylistic/no-extra-semi': 'error',
  189.  
  190.         // disallow the use of leading or trailing decimal points in numeric literals
  191.         '@stylistic/no-floating-decimal': 'error',
  192.  
  193.         // disallow un-paren'd mixes of different operators
  194.         // https://eslint.style/rules/default/no-mixed-operators
  195.         '@stylistic/no-mixed-operators': ['error', {
  196.           allowSamePrecedence: false,
  197.  
  198.           // the list of arithmetic groups disallows mixing `%` and `**`
  199.           // with other arithmetic operators.
  200.           groups: [
  201.             ['%', '**'],
  202.             ['%', '+'],
  203.             ['%', '-'],
  204.             ['%', '*'],
  205.             ['%', '/'],
  206.             ['/', '*'],
  207.             ['&', '|', '<<', '>>', '>>>'],
  208.             ['==', '!=', '===', '!=='],
  209.             ['&&', '||'],
  210.           ],
  211.         }],
  212.  
  213.         // disallow mixed spaces and tabs for indentation
  214.         '@stylistic/no-mixed-spaces-and-tabs': 'error',
  215.  
  216.         // disallow use of multiple spaces
  217.         '@stylistic/no-multi-spaces': ['error', {
  218.           ignoreEOLComments: false,
  219.         }],
  220.  
  221.         // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
  222.         // https://eslint.style/rules/default/no-multiple-empty-lines
  223.         '@stylistic/no-multiple-empty-lines': ['error', {
  224.           max: 1,
  225.           maxBOF: 0,
  226.           maxEOF: 0,
  227.         }],
  228.  
  229.         // disallow trailing whitespace at the end of lines
  230.         '@stylistic/no-trailing-spaces': ['error', {
  231.           ignoreComments: false,
  232.           skipBlankLines: false,
  233.         }],
  234.  
  235.         // disallow whitespace before properties
  236.         // https://eslint.style/rules/default/no-whitespace-before-property
  237.         '@stylistic/no-whitespace-before-property': 'error',
  238.  
  239.         // enforce the location of single-line statements
  240.         // https://eslint.style/rules/default/nonblock-statement-body-position
  241.         '@stylistic/nonblock-statement-body-position': ['error', 'beside', {
  242.           overrides: {},
  243.         }],
  244.  
  245.         // enforce line breaks between braces
  246.         // https://eslint.style/rules/default/object-curly-newline
  247.         '@stylistic/object-curly-newline': ['error', {
  248.           ExportDeclaration: {
  249.             consistent: true,
  250.             minProperties: 4,
  251.           },
  252.           ImportDeclaration: {
  253.             consistent: true,
  254.             minProperties: 6,
  255.           },
  256.           ObjectExpression: {
  257.             consistent: true,
  258.             minProperties: 4,
  259.           },
  260.           ObjectPattern: {
  261.             consistent: true,
  262.             minProperties: 4,
  263.           },
  264.         }],
  265.  
  266.         // require padding inside curly braces
  267.         '@stylistic/object-curly-spacing': ['error', 'always'],
  268.  
  269.         // enforce "same line" or "multiple line" on object properties.
  270.         // https://eslint.style/rules/default/object-property-newline
  271.         '@stylistic/object-property-newline': ['error', {
  272.           allowAllPropertiesOnSameLine: true,
  273.         }],
  274.  
  275.         // require a newline around variable declaration
  276.         // https://eslint.style/rules/default/one-var-declaration-per-line
  277.         '@stylistic/one-var-declaration-per-line': ['error', 'always'],
  278.  
  279.         // Requires operator at the beginning of the line in multiline statements
  280.         // https://eslint.style/rules/default/operator-linebreak
  281.         '@stylistic/operator-linebreak': ['error', 'before', {
  282.           overrides: {
  283.             '=': 'none',
  284.           },
  285.         }],
  286.  
  287.         // disallow padding within blocks
  288.         '@stylistic/padded-blocks': ['error', {
  289.           blocks: 'never',
  290.           classes: 'never',
  291.           switches: 'never',
  292.         }, {
  293.           allowSingleLineBlocks: true,
  294.         }],
  295.  
  296.         // Require or disallow padding lines between statements
  297.         // https://eslint.style/rules/default/padding-line-between-statements
  298.         '@stylistic/padding-line-between-statements': [
  299.           'error',
  300.           {
  301.             blankLine: 'always',
  302.             next: '*',
  303.             prev: 'directive',
  304.           },
  305.         ],
  306.  
  307.         // require quotes around object literal property names
  308.         // https://eslint.style/rules/default/quote-props.html
  309.         '@stylistic/quote-props': ['error', 'as-needed', {
  310.           keywords: false,
  311.           numbers: false,
  312.           unnecessary: true,
  313.         }],
  314.  
  315.         // specify whether double or single quotes should be used
  316.         '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
  317.  
  318.         // enforce spacing between object rest-spread
  319.         // https://eslint.style/rules/default/rest-spread-spacing
  320.         '@stylistic/rest-spread-spacing': ['error', 'never'],
  321.  
  322.         // require or disallow space before blocks
  323.         '@stylistic/space-before-blocks': 'error',
  324.  
  325.         // require or disallow space before function opening parenthesis
  326.         // https://eslint.style/rules/default/space-before-function-paren
  327.         '@stylistic/space-before-function-paren': ['error', {
  328.           anonymous: 'always',
  329.           asyncArrow: 'always',
  330.           named: 'never',
  331.         }],
  332.  
  333.         // require or disallow spaces inside parentheses
  334.         '@stylistic/space-in-parens': ['error', 'never'],
  335.  
  336.         // require spaces around operators
  337.         '@stylistic/space-infix-ops': 'error',
  338.  
  339.         // Require or disallow spaces before/after unary operators
  340.         // https://eslint.style/rules/default/space-unary-ops
  341.         '@stylistic/space-unary-ops': ['error', {
  342.           nonwords: false,
  343.           overrides: {},
  344.           words: true,
  345.         }],
  346.  
  347.         // require or disallow a space immediately following the // or /* in a comment
  348.         // https://eslint.style/rules/default/spaced-comment
  349.         '@stylistic/spaced-comment': ['error', 'always', {
  350.           block: {
  351.             // space here to support sprockets directives and flow comment types
  352.             balanced: true,
  353.             exceptions: ['-', '+'],
  354.             markers: ['=', '!', ':', '::'],
  355.           },
  356.           line: {
  357.             exceptions: ['-', '+'],
  358.             markers: ['=', '!', '/'], // space here to support sprockets directives, slash for TS /// comments
  359.           },
  360.         }],
  361.  
  362.         // Enforce spacing around colons of switch statements
  363.         // https://eslint.style/rules/default/switch-colon-spacing
  364.         '@stylistic/switch-colon-spacing': ['error', {
  365.           after: true,
  366.           before: false,
  367.         }],
  368.  
  369.         // enforce usage of spacing in template strings
  370.         // https://eslint.style/rules/default/template-curly-spacing
  371.         '@stylistic/template-curly-spacing': 'error',
  372.  
  373.         // Require or disallow spacing between template tags and their literals
  374.         // https://eslint.style/rules/default/template-tag-spacing
  375.         '@stylistic/template-tag-spacing': ['error', 'never'],
  376.  
  377.         // require immediate function invocation to be wrapped in parentheses
  378.         // https://eslint.style/rules/default/wrap-iife.html
  379.         '@stylistic/wrap-iife': ['error', 'inside', { functionPrototypeMethods: false }],
  380.  
  381.         // enforce spacing around the * in yield* expressions
  382.         // https://eslint.style/rules/default/yield-star-spacing
  383.         '@stylistic/yield-star-spacing': ['error', 'after'],
  384.  
  385.         // Disabled until they fix it: https://github.com/eslint/eslint/issues/12970
  386.         // '@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
  387.  
  388.         // https://eslint.org/docs/rules/padding-line-between-statements
  389.         'padding-line-between-statements': [
  390.           'error',
  391.           { blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
  392.           {
  393.             blankLine: 'any',
  394.             prev: ['const', 'let', 'var'],
  395.             next: ['const', 'let', 'var'],
  396.           },
  397.           { blankLine: 'always', prev: ['case', 'default'], next: '*' },
  398.           { blankLine: 'always', prev: 'directive', next: '*' },
  399.           { blankLine: 'always', prev: 'function', next: '*' },
  400.           { blankLine: 'always', prev: '*', next: 'function' },
  401.           { blankLine: 'always', prev: 'if', next: '*' },
  402.           { blankLine: 'always', prev: '*', next: 'if' },
  403.           { blankLine: 'any', prev: 'directive', next: 'directive' },
  404.         ],
  405.  
  406.         'vue/padding-line-between-tags': ['error', [
  407.           { blankLine: 'always', prev: '*', next: '*' },
  408.         ]],
  409.  
  410.         'vue/padding-lines-in-component-definition': ['error'],
  411.  
  412.         'vue/new-line-between-multi-line-property': [
  413.           'error',
  414.           {
  415.             minLineOfMultilineProperty: 2,
  416.           },
  417.         ],
  418.  
  419.         'vue/object-curly-spacing': ['error', 'always'],
  420.  
  421.         'vue/padding-line-between-blocks': ['error', 'always'],
  422.       },
  423.     })
  424.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement