<commit_before>'use strict';
/* @flow */
/* eslint-disable max-len */

module.exports = {
  root: true,

  parser: 'babel-eslint',

  parserOptions: {
    ecmaVersion: 7,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
      experimentalObjectRestSpread: true,
    },
  },

  // https://github.com/sindresorhus/globals/blob/master/globals.json
  env: {
    browser: true,
    es6: true,
  },

  globals: {
    document: false,
    window: false,
    HTMLElement: false,
    WebSocket: false,
  },

  rules: {
    // Possible Errors (http://eslint.org/docs/rules/#possible-errors)
    'comma-dangle': [1, {arrays: 'always-multiline', objects: 'always-multiline', imports: 'always-multiline', exports: 'always-multiline', functions: 'always-multiline'}],
    'no-cond-assign': 1,
    'no-console': 1,
    'no-constant-condition': [1, {checkLoops: false}],
    'no-control-regex': 1,
    'no-debugger': 1,
    'no-dupe-args': 1,
    'no-dupe-keys': 1,
    'no-duplicate-case': 1,
    'no-empty': [1, {allowEmptyCatch: true}],
    'no-empty-character-class': 1,
    'no-ex-assign': 1,
    'no-extra-boolean-cast': 1,
    'no-extra-parens': 0,
    'no-extra-semi': 1,
    'no-func-assign': 1,
    'no-inner-declarations': 1,
    'no-invalid-regexp': 1,
    'no-irregular-whitespace': 1,
    'no-obj-calls': 1,
    'no-prototype-builtins': 0,
    'no-regex-spaces': 1,
    'no-sparse-arrays': 1,
    'no-template-curly-in-string': 0,
    'no-unexpected-multiline': 1,
    'no-unreachable': 1,
    'no-unsafe-finally': 1,
    'no-unsafe-negation': 1,
    'use-isnan': 1,
    'valid-jsdoc': 0,
    'valid-typeof': 1,

    // Best Practices (http://eslint.org/docs/rules/#best-practices)
    'accessor-pairs': 1,
    'array-callback-return': 0,
    'block-scoped-var': 0,
    'class-methods-use-this': 0,
    'complexity': 0,
    'consistent-return': 0,
    'curly': 1,
    // 'curly': [1, 'multi-line', 'consistent'],
    'default-case': 0,
    'dot-location': [1, 'property'],
    'dot-notation': 1,
    'eqeqeq': [1, 'allow-null'],
    'guard-for-in': 0,
    'no-alert': 1,
    'no-caller': 1,
    'no-case-declarations': 0,
    'no-div-regex': 1,
    'no-else-return': 0,
    'no-empty-function': 0,
    'no-empty-pattern': 1,
    'no-eq-null': 0,
    'no-eval': 1,
    'no-extend-native': 1,
    'no-extra-bind': 1,
    'no-extra-label': 1,
    'no-fallthrough': 1,
    'no-floating-decimal': 1,
    'no-global-assign': 1,
    'no-implicit-coercion': 1,
    'no-implicit-globals': 0,
    'no-implied-eval': 1,
    'no-invalid-this': 0,
    'no-iterator': 1,
    'no-labels': 1,
    'no-lone-blocks': 1,
    'no-loop-func': 0,
    'no-magic-numbers': 0,
    'no-multi-spaces': 1,
    'no-multi-str': 0,
    'no-new': 1,
    'no-new-func': 1,
    'no-new-wrappers': 1,
    'no-octal': 1,
    'no-octal-escape': 1,
    'no-param-reassign': 1,
    'no-proto': 1,
    'no-redeclare': [1, {builtinGlobals: true}],
    'no-return-assign': 1,
    'no-script-url': 1,
    'no-self-assign': 1,
    'no-self-compare': 1,
    'no-sequences': 1,
    'no-throw-literal': 0,
    'no-unmodified-loop-condition': 0,
    // 'no-unused-expressions': 1,
    'no-unused-labels': 1,
    'no-useless-call': 1,
    'no-useless-concat': 1,
    'no-useless-escape': 1,
    'no-useless-return': 0,
    'no-void': 1,
    'no-warning-comments': 0,
    'no-with': 1,
    'radix': 1,
    'vars-on-top': 0,
    'wrap-iife': [1, 'inside'],
    'yoda': 1,

    // Strict Mode (http://eslint.org/docs/rules/#strict-mode)
    'strict': 0,

    // Variables (http://eslint.org/docs/rules/#variables)
    'init-declarations': 0,
    'no-catch-shadow': 1,
    'no-delete-var': 1,
    'no-label-var': 1,
    'no-restricted-globals': 0,
    'no-shadow': 1,
    'no-shadow-restricted-names': 1,
    'no-undef': 1,
    'no-undef-init': 0,
    'no-undefined': 0,
    'no-unused-vars': [1, {args: 'none'}],
    'no-use-before-define': 0,

    // Node.js and CommonJS (http://eslint.org/docs/rules/#nodejs-and-commonjs)
    'callback-return': 0,
    'global-require': 0,
    'handle-callback-err': 1,
    'no-mixed-requires': 1,
    'no-new-require': 1,
    'no-path-concat': 1,
    'no-process-env': 0,
    'no-process-exit': 0,
    'no-restricted-modules': 0,
    'no-restricted-properties': 0,
    'no-sync': 0,

    // Stylistic Issues (http://eslint.org/docs/rules/#stylistic-issues)
    'array-bracket-spacing': 1,
    'block-spacing': 1,
    'brace-style': [1, '1tbs', {allowSingleLine: true}],
    'camelcase': 0,
    'comma-spacing': 1,
    'comma-style': 1,
    'computed-property-spacing': 1,
    'consistent-this': 0,
    'eol-last': 1,
    'func-call-spacing': 1,
    'func-name-matching': 0,
    'func-names': 0,
    'func-style': 0,
    'id-blacklist': 0,
    'id-length': 0,
    'id-match': 0,
    'indent': [1, 2, {SwitchCase: 1}],
    'jsx-quotes': [1, 'prefer-double'],
    'key-spacing': [1, {beforeColon: false, afterColon: true}],
    'keyword-spacing': 1,
    'line-comment-position': 0,
    'linebreak-style': 1,
    'lines-around-comment': 0,
    'lines-around-directive': 0,
    'max-depth': 0,
    'max-len': [1, 100, {tabWidth: 2, ignoreUrls: true}],
    'max-lines': 0,
    'max-nested-callbacks': 0,
    'max-params': 0,
    'max-statements': 0,
    'max-statements-per-line': 0,
    'multiline-ternary': 0,
    'new-cap': 0,
    'new-parens': 1,
    'newline-after-var': 0,
    'newline-before-return': 0,
    'newline-per-chained-call': 0,
    'no-array-constructor': 1,
    'no-bitwise': 1,
    'no-continue': 0,
    'no-inline-comments': 0,
    'no-lonely-if': 0,
    'no-mixed-operators': 0,
    'no-mixed-spaces-and-tabs': 1,
    'no-multiple-empty-lines': [1, {max: 2, maxBOF: 0, maxEOF: 1}],
    'no-negated-condition': 0,
    'no-nested-ternary': 0,
    'no-new-object': 1,
    'no-plusplus': 0,
    'no-restricted-syntax': 0,
    'no-tabs': 1,
    'no-ternary': 0,
    'no-trailing-spaces': 1,
    'no-underscore-dangle': 0,
    'no-unneeded-ternary': 0,
    'no-whitespace-before-property': 1,
    'object-curly-newline': 0,
    'object-curly-spacing': 1,
    'object-property-newline': 0,
    'one-var': [1, 'never'],
    'one-var-declaration-per-line': 0,
    'operator-assignment': 1,
    'operator-linebreak': 0,
    'padded-blocks': [1, 'never'],
    'quote-props': [1, 'consistent-as-needed'],
    'quotes': [1, 'single', 'avoid-escape'],
    'require-jsdoc': 0,
    'semi-spacing': 1,
    'semi': 1,
    'sort-keys': 0,
    'sort-vars': 0,
    'space-before-blocks': 1,
    'space-before-function-paren': [1, {anonymous: 'never', named: 'never', asyncArrow: 'always'}],
    'space-in-parens': [1, 'never'],
    'space-infix-ops': 1,
    'space-unary-ops': 1,
    'spaced-comment': [1, 'always', {line: {exceptions: ['-']}, block: {balanced: true}}],
    'unicode-bom': [1, 'never'],
    'wrap-regex': 0,

    // ECMAScript 6 (http://eslint.org/docs/rules/#ecmascript-6)
    'arrow-body-style': 0,
    'arrow-parens': 0, // Enforced by babel/arrow-parens
    'arrow-spacing': 1,
    'constructor-super': 1,
    'generator-star-spacing': 1,
    'no-class-assign': 1,
    'no-confusing-arrow': [1, {allowParens: true}],
    'no-const-assign': 1,
    'no-dupe-class-members': 1,
    'no-duplicate-imports': 0,
    'no-new-symbol': 1,
    'no-restricted-imports': 0,
    'no-this-before-super': 1,
    'no-useless-computed-key': 1,
    'no-useless-constructor': 0,
    'no-var': 1,
    'no-useless-rename': 1,
    'object-shorthand': 1,
    'prefer-arrow-callback': [1, {allowNamedFunctions: true}],
    'prefer-const': 1,
    'prefer-numeric-literals': 0,
    'prefer-rest-params': 0,
    'prefer-spread': 1,
    'prefer-template': 1,
    'require-yield': 0,
    'rest-spread-spacing': 1,
    'sort-imports': 0,
    'symbol-description': 1,
    'template-curly-spacing': 1,
    'yield-star-spacing': 1,

    // Babel (https://github.com/babel/eslint-plugin-babel)
    'babel/array-bracket-spacing': 0,
    'babel/arrow-parens': [1, 'as-needed'],
    'babel/func-params-comma-dangle': 0,
    'babel/generator-star-spacing': 0,
    'babel/new-cap': 0,
    'babel/object-curly-spacing': 0,
    'babel/object-shorthand': 0,
    // Babel (not in eslint)
    'babel/flow-object-type': 0,
    'babel/no-await-in-loop': 1,

    // flowtype (https://github.com/gajus/eslint-plugin-flowtype)
    'flowtype/boolean-style': 1,
    'flowtype/define-flow-type': 1,
    'flowtype/delimiter-dangle': [1, 'always-multiline'],
    'flowtype/generic-spacing': 1,
    'flowtype/no-dupe-keys': 0,
    'flowtype/no-weak-types': 0,
    'flowtype/object-type-delimiter': 1,
    'flowtype/require-parameter-type': 0,
    'flowtype/require-return-type': 0,
    'flowtype/require-valid-file-annotation': 0,
    'flowtype/semi': 1,
    'flowtype/sort-keys': 0,
    'flowtype/space-after-type-colon': [1, 'always'],
    'flowtype/space-before-generic-bracket': 1,
    'flowtype/space-before-type-colon': 1,
    'flowtype/type-id-match': 0,
    'flowtype/union-intersection-spacing': 1,
    'flowtype/use-flow-type': 1,
    'flowtype/valid-syntax': 0,

    // prefer-object-spread (https://github.com/bryanrsmith/eslint-plugin-prefer-object-spread)
    'prefer-object-spread/prefer-object-spread': 1,
  },

  plugins: [
    'babel',
    'flowtype',
    'prefer-object-spread',
  ],
};
<commit_msg>update eslintrc to be more strict on flowtypes<commit_after>'use strict';
/* @flow */
/* eslint-disable max-len */

module.exports = {
  root: true,

  parser: 'babel-eslint',

  parserOptions: {
    ecmaVersion: 7,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
      experimentalObjectRestSpread: true,
    },
  },

  // https://github.com/sindresorhus/globals/blob/master/globals.json
  env: {
    browser: true,
    es6: true,
  },

  globals: {
    document: false,
    window: false,
    HTMLElement: false,
    WebSocket: false,
  },

  rules: {
    // Possible Errors (http://eslint.org/docs/rules/#possible-errors)
    'comma-dangle': [1, {arrays: 'always-multiline', objects: 'always-multiline', imports: 'always-multiline', exports: 'always-multiline', functions: 'always-multiline'}],
    'no-cond-assign': 1,
    'no-console': 1,
    'no-constant-condition': [1, {checkLoops: false}],
    'no-control-regex': 1,
    'no-debugger': 1,
    'no-dupe-args': 1,
    'no-dupe-keys': 1,
    'no-duplicate-case': 1,
    'no-empty': [1, {allowEmptyCatch: true}],
    'no-empty-character-class': 1,
    'no-ex-assign': 1,
    'no-extra-boolean-cast': 1,
    'no-extra-parens': 0,
    'no-extra-semi': 1,
    'no-func-assign': 1,
    'no-inner-declarations': 1,
    'no-invalid-regexp': 1,
    'no-irregular-whitespace': 1,
    'no-obj-calls': 1,
    'no-prototype-builtins': 0,
    'no-regex-spaces': 1,
    'no-sparse-arrays': 1,
    'no-template-curly-in-string': 0,
    'no-unexpected-multiline': 1,
    'no-unreachable': 1,
    'no-unsafe-finally': 1,
    'no-unsafe-negation': 1,
    'use-isnan': 1,
    'valid-jsdoc': 0,
    'valid-typeof': 1,

    // Best Practices (http://eslint.org/docs/rules/#best-practices)
    'accessor-pairs': 1,
    'array-callback-return': 0,
    'block-scoped-var': 0,
    'class-methods-use-this': 0,
    'complexity': 0,
    'consistent-return': 0,
    'curly': 1,
    // 'curly': [1, 'multi-line', 'consistent'],
    'default-case': 0,
    'dot-location': [1, 'property'],
    'dot-notation': 1,
    'eqeqeq': [1, 'allow-null'],
    'guard-for-in': 0,
    'no-alert': 1,
    'no-caller': 1,
    'no-case-declarations': 0,
    'no-div-regex': 1,
    'no-else-return': 0,
    'no-empty-function': 0,
    'no-empty-pattern': 1,
    'no-eq-null': 0,
    'no-eval': 1,
    'no-extend-native': 1,
    'no-extra-bind': 1,
    'no-extra-label': 1,
    'no-fallthrough': 1,
    'no-floating-decimal': 1,
    'no-global-assign': 1,
    'no-implicit-coercion': 1,
    'no-implicit-globals': 0,
    'no-implied-eval': 1,
    'no-invalid-this': 0,
    'no-iterator': 1,
    'no-labels': 1,
    'no-lone-blocks': 1,
    'no-loop-func': 0,
    'no-magic-numbers': 0,
    'no-multi-spaces': 1,
    'no-multi-str': 0,
    'no-new': 1,
    'no-new-func': 1,
    'no-new-wrappers': 1,
    'no-octal': 1,
    'no-octal-escape': 1,
    'no-param-reassign': 1,
    'no-proto': 1,
    'no-redeclare': [1, {builtinGlobals: true}],
    'no-return-assign': 1,
    'no-script-url': 1,
    'no-self-assign': 1,
    'no-self-compare': 1,
    'no-sequences': 1,
    'no-throw-literal': 0,
    'no-unmodified-loop-condition': 0,
    // 'no-unused-expressions': 1,
    'no-unused-labels': 1,
    'no-useless-call': 1,
    'no-useless-concat': 1,
    'no-useless-escape': 1,
    'no-useless-return': 0,
    'no-void': 1,
    'no-warning-comments': 0,
    'no-with': 1,
    'radix': 1,
    'vars-on-top': 0,
    'wrap-iife': [1, 'inside'],
    'yoda': 1,

    // Strict Mode (http://eslint.org/docs/rules/#strict-mode)
    'strict': 0,

    // Variables (http://eslint.org/docs/rules/#variables)
    'init-declarations': 0,
    'no-catch-shadow': 1,
    'no-delete-var': 1,
    'no-label-var': 1,
    'no-restricted-globals': 0,
    'no-shadow': 1,
    'no-shadow-restricted-names': 1,
    'no-undef': 1,
    'no-undef-init': 0,
    'no-undefined': 0,
    'no-unused-vars': [1, {args: 'none'}],
    'no-use-before-define': 0,

    // Node.js and CommonJS (http://eslint.org/docs/rules/#nodejs-and-commonjs)
    'callback-return': 0,
    'global-require': 0,
    'handle-callback-err': 1,
    'no-mixed-requires': 1,
    'no-new-require': 1,
    'no-path-concat': 1,
    'no-process-env': 0,
    'no-process-exit': 0,
    'no-restricted-modules': 0,
    'no-restricted-properties': 0,
    'no-sync': 0,

    // Stylistic Issues (http://eslint.org/docs/rules/#stylistic-issues)
    'array-bracket-spacing': 1,
    'block-spacing': 1,
    'brace-style': [1, '1tbs', {allowSingleLine: true}],
    'camelcase': 0,
    'comma-spacing': 1,
    'comma-style': 1,
    'computed-property-spacing': 1,
    'consistent-this': 0,
    'eol-last': 1,
    'func-call-spacing': 1,
    'func-name-matching': 0,
    'func-names': 0,
    'func-style': 0,
    'id-blacklist': 0,
    'id-length': 0,
    'id-match': 0,
    'indent': [1, 2, {SwitchCase: 1}],
    'jsx-quotes': [1, 'prefer-double'],
    'key-spacing': [1, {beforeColon: false, afterColon: true}],
    'keyword-spacing': 1,
    'line-comment-position': 0,
    'linebreak-style': 1,
    'lines-around-comment': 0,
    'lines-around-directive': 0,
    'max-depth': 0,
    'max-len': [1, 100, {tabWidth: 2, ignoreUrls: true}],
    'max-lines': 0,
    'max-nested-callbacks': 0,
    'max-params': 0,
    'max-statements': 0,
    'max-statements-per-line': 0,
    'multiline-ternary': 0,
    'new-cap': 0,
    'new-parens': 1,
    'newline-after-var': 0,
    'newline-before-return': 0,
    'newline-per-chained-call': 0,
    'no-array-constructor': 1,
    'no-bitwise': 1,
    'no-continue': 0,
    'no-inline-comments': 0,
    'no-lonely-if': 0,
    'no-mixed-operators': 0,
    'no-mixed-spaces-and-tabs': 1,
    'no-multiple-empty-lines': [1, {max: 2, maxBOF: 0, maxEOF: 1}],
    'no-negated-condition': 0,
    'no-nested-ternary': 0,
    'no-new-object': 1,
    'no-plusplus': 0,
    'no-restricted-syntax': 0,
    'no-tabs': 1,
    'no-ternary': 0,
    'no-trailing-spaces': 1,
    'no-underscore-dangle': 0,
    'no-unneeded-ternary': 0,
    'no-whitespace-before-property': 1,
    'object-curly-newline': 0,
    'object-curly-spacing': 1,
    'object-property-newline': 0,
    'one-var': [1, 'never'],
    'one-var-declaration-per-line': 0,
    'operator-assignment': 1,
    'operator-linebreak': 0,
    'padded-blocks': [1, 'never'],
    'quote-props': [1, 'consistent-as-needed'],
    'quotes': [1, 'single', 'avoid-escape'],
    'require-jsdoc': 0,
    'semi-spacing': 1,
    'semi': 1,
    'sort-keys': 0,
    'sort-vars': 0,
    'space-before-blocks': 1,
    'space-before-function-paren': [1, {anonymous: 'never', named: 'never', asyncArrow: 'always'}],
    'space-in-parens': [1, 'never'],
    'space-infix-ops': 1,
    'space-unary-ops': 1,
    'spaced-comment': [1, 'always', {line: {exceptions: ['-']}, block: {balanced: true}}],
    'unicode-bom': [1, 'never'],
    'wrap-regex': 0,

    // ECMAScript 6 (http://eslint.org/docs/rules/#ecmascript-6)
    'arrow-body-style': 0,
    'arrow-parens': 0, // Enforced by babel/arrow-parens
    'arrow-spacing': 1,
    'constructor-super': 1,
    'generator-star-spacing': 1,
    'no-class-assign': 1,
    'no-confusing-arrow': [1, {allowParens: true}],
    'no-const-assign': 1,
    'no-dupe-class-members': 1,
    'no-duplicate-imports': 0,
    'no-new-symbol': 1,
    'no-restricted-imports': 0,
    'no-this-before-super': 1,
    'no-useless-computed-key': 1,
    'no-useless-constructor': 0,
    'no-var': 1,
    'no-useless-rename': 1,
    'object-shorthand': 1,
    'prefer-arrow-callback': [1, {allowNamedFunctions: true}],
    'prefer-const': 1,
    'prefer-numeric-literals': 0,
    'prefer-rest-params': 0,
    'prefer-spread': 1,
    'prefer-template': 1,
    'require-yield': 0,
    'rest-spread-spacing': 1,
    'sort-imports': 0,
    'symbol-description': 1,
    'template-curly-spacing': 1,
    'yield-star-spacing': 1,

    // Babel (https://github.com/babel/eslint-plugin-babel)
    'babel/array-bracket-spacing': 0,
    'babel/arrow-parens': [1, 'as-needed'],
    'babel/func-params-comma-dangle': 0,
    'babel/generator-star-spacing': 0,
    'babel/new-cap': 0,
    'babel/object-curly-spacing': 0,
    'babel/object-shorthand': 0,
    // Babel (not in eslint)
    'babel/flow-object-type': 0,
    'babel/no-await-in-loop': 1,

    // flowtype (https://github.com/gajus/eslint-plugin-flowtype)
    'flowtype/boolean-style': [1, 'bool'],
    'flowtype/define-flow-type': 1,
    'flowtype/delimiter-dangle': [1, 'always-multiline'],
    'flowtype/generic-spacing': 1,
    'flowtype/no-dupe-keys': 1,
    'flowtype/no-weak-types': 0,
    'flowtype/object-type-delimiter': 1,
    'flowtype/require-parameter-type': [2, 'always'],
    'flowtype/require-return-type': [
      2, 'always', { annotateUndefined: 'always' }
    ],
    'flowtype/require-valid-file-annotation': 2,
    'flowtype/semi': 1,
    'flowtype/sort-keys': 0,
    'flowtype/space-after-type-colon': [1, 'always'],
    'flowtype/space-before-generic-bracket': 1,
    'flowtype/space-before-type-colon': 1,
    'flowtype/type-id-match': 0,
    'flowtype/union-intersection-spacing': 1,
    'flowtype/use-flow-type': 1,
    'flowtype/valid-syntax': 0,

    // prefer-object-spread (https://github.com/bryanrsmith/eslint-plugin-prefer-object-spread)
    'prefer-object-spread/prefer-object-spread': 1,
  },

  plugins: [
    'babel',
    'flowtype',
    'prefer-object-spread',
  ],
};
<|endoftext|>


<commit_before>"use strict";

const path = require("path");

const INTERNAL_FILES = {
    CLI_ENGINE_PATTERN: "lib/cli-engine/**/*",
    INIT_PATTERN: "lib/init/**/*",
    LINTER_PATTERN: "lib/linter/**/*",
    RULE_TESTER_PATTERN: "lib/rule-tester/**/*",
    RULES_PATTERN: "lib/rules/**/*",
    SOURCE_CODE_PATTERN: "lib/source-code/**/*"
};

/**
 * Resolve an absolute path or glob pattern.
 * @param {string} pathOrPattern the path or glob pattern.
 * @returns {string} The resolved path or glob pattern.
 */
function resolveAbsolutePath(pathOrPattern) {
    return path.resolve(__dirname, pathOrPattern);
}

/**
 * Create an array of `no-restricted-require` entries for ESLint's core files.
 * @param {string} [pattern] The glob pattern to create the entries for.
 * @returns {Object[]} The array of `no-restricted-require` entries.
 */
function createInternalFilesPatterns(pattern = null) {
    return Object.values(INTERNAL_FILES)
        .filter(p => p !== pattern)
        .map(p => ({
            name: [

                // Disallow all children modules.
                resolveAbsolutePath(p),

                // Allow the main `index.js` module.
                `!${resolveAbsolutePath(p.replace(/\*\*\/\*$/u, "index.js"))}`
            ]
        }));
}

module.exports = {
    root: true,
    plugins: [
        "eslint-plugin",
        "internal-rules"
    ],
    extends: [
        "eslint",
        "plugin:eslint-plugin/recommended"
    ],
    parserOptions: {
        ecmaVersion: 2021
    },

    /*
     * it fixes eslint-plugin-jsdoc's reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names"
     * refs: https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
     */
    settings: {
        jsdoc: {
            mode: "typescript"
        }
    },
    rules: {
        "eslint-plugin/prefer-message-ids": "error",
        "eslint-plugin/prefer-output-null": "error",
        "eslint-plugin/prefer-placeholders": "error",
        "eslint-plugin/prefer-replace-text": "error",
        "eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
        "eslint-plugin/require-meta-docs-description": "error",
        "eslint-plugin/test-case-property-ordering": "error",
        "eslint-plugin/test-case-shorthand-strings": "error",
        "internal-rules/multiline-comment-style": "error"
    },
    overrides: [
        {
            files: ["lib/rules/*", "tools/internal-rules/*"],
            excludedFiles: ["index.js"],
            rules: {
                "internal-rules/no-invalid-meta": "error"
            }
        },
        {
            files: ["lib/rules/*"],
            excludedFiles: ["index.js"],
            rules: {
                "eslint-plugin/require-meta-docs-url": ["error", { pattern: "https://eslint.org/docs/rules/{{name}}" }]
            }
        },
        {
            files: ["tests/**/*"],
            env: { mocha: true },
            rules: {
                "no-restricted-syntax": ["error", {
                    selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']",
                    message: "`assert.doesNotThrow()` should be replaced with a comment next to the code."
                }]
            }
        },

        // Restrict relative path imports
        {
            files: ["lib/*"],
            excludedFiles: ["lib/unsupported-api.js"],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns()
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.CLI_ENGINE_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN),
                    resolveAbsolutePath("lib/init/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.INIT_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.INIT_PATTERN),
                    resolveAbsolutePath("lib/rule-tester/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.LINTER_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/init/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.RULES_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/init/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/source-code/index.js")
                ]]
            }
        },
        {
            files: ["lib/shared/**/*"],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(),
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/init/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/source-code/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.SOURCE_CODE_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/init/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/rules/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.RULE_TESTER_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN),
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/init/index.js")
                ]]
            }
        }
    ]
};
<commit_msg>chore: remove `lib/init` from eslint config (#15748)<commit_after>"use strict";

const path = require("path");

const INTERNAL_FILES = {
    CLI_ENGINE_PATTERN: "lib/cli-engine/**/*",
    LINTER_PATTERN: "lib/linter/**/*",
    RULE_TESTER_PATTERN: "lib/rule-tester/**/*",
    RULES_PATTERN: "lib/rules/**/*",
    SOURCE_CODE_PATTERN: "lib/source-code/**/*"
};

/**
 * Resolve an absolute path or glob pattern.
 * @param {string} pathOrPattern the path or glob pattern.
 * @returns {string} The resolved path or glob pattern.
 */
function resolveAbsolutePath(pathOrPattern) {
    return path.resolve(__dirname, pathOrPattern);
}

/**
 * Create an array of `no-restricted-require` entries for ESLint's core files.
 * @param {string} [pattern] The glob pattern to create the entries for.
 * @returns {Object[]} The array of `no-restricted-require` entries.
 */
function createInternalFilesPatterns(pattern = null) {
    return Object.values(INTERNAL_FILES)
        .filter(p => p !== pattern)
        .map(p => ({
            name: [

                // Disallow all children modules.
                resolveAbsolutePath(p),

                // Allow the main `index.js` module.
                `!${resolveAbsolutePath(p.replace(/\*\*\/\*$/u, "index.js"))}`
            ]
        }));
}

module.exports = {
    root: true,
    plugins: [
        "eslint-plugin",
        "internal-rules"
    ],
    extends: [
        "eslint",
        "plugin:eslint-plugin/recommended"
    ],
    parserOptions: {
        ecmaVersion: 2021
    },

    /*
     * it fixes eslint-plugin-jsdoc's reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names"
     * refs: https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
     */
    settings: {
        jsdoc: {
            mode: "typescript"
        }
    },
    rules: {
        "eslint-plugin/prefer-message-ids": "error",
        "eslint-plugin/prefer-output-null": "error",
        "eslint-plugin/prefer-placeholders": "error",
        "eslint-plugin/prefer-replace-text": "error",
        "eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
        "eslint-plugin/require-meta-docs-description": "error",
        "eslint-plugin/test-case-property-ordering": "error",
        "eslint-plugin/test-case-shorthand-strings": "error",
        "internal-rules/multiline-comment-style": "error"
    },
    overrides: [
        {
            files: ["lib/rules/*", "tools/internal-rules/*"],
            excludedFiles: ["index.js"],
            rules: {
                "internal-rules/no-invalid-meta": "error"
            }
        },
        {
            files: ["lib/rules/*"],
            excludedFiles: ["index.js"],
            rules: {
                "eslint-plugin/require-meta-docs-url": ["error", { pattern: "https://eslint.org/docs/rules/{{name}}" }]
            }
        },
        {
            files: ["tests/**/*"],
            env: { mocha: true },
            rules: {
                "no-restricted-syntax": ["error", {
                    selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']",
                    message: "`assert.doesNotThrow()` should be replaced with a comment next to the code."
                }]
            }
        },

        // Restrict relative path imports
        {
            files: ["lib/*"],
            excludedFiles: ["lib/unsupported-api.js"],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns()
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.CLI_ENGINE_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.CLI_ENGINE_PATTERN)
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.LINTER_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.LINTER_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.RULES_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.RULES_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/source-code/index.js")
                ]]
            }
        },
        {
            files: ["lib/shared/**/*"],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(),
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/source-code/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.SOURCE_CODE_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.SOURCE_CODE_PATTERN),
                    "fs",
                    resolveAbsolutePath("lib/cli-engine/index.js"),
                    resolveAbsolutePath("lib/linter/index.js"),
                    resolveAbsolutePath("lib/rule-tester/index.js"),
                    resolveAbsolutePath("lib/rules/index.js")
                ]]
            }
        },
        {
            files: [INTERNAL_FILES.RULE_TESTER_PATTERN],
            rules: {
                "node/no-restricted-require": ["error", [
                    ...createInternalFilesPatterns(INTERNAL_FILES.RULE_TESTER_PATTERN),
                    resolveAbsolutePath("lib/cli-engine/index.js")
                ]]
            }
        }
    ]
};
<|endoftext|>


<commit_before>'use strict';

module.exports = {
  root: true,
  env: {
    browser: false,
    es6: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 2018
  },
  rules: {
    'accessor-pairs': 'error',
    'array-bracket-spacing': ['error', 'never'],
    'arrow-body-style': ['error', 'always'],
    'arrow-parens': ['error', 'always'],
    'arrow-spacing': ['error', { 'before': true, 'after': true }],
    'block-spacing': ['error', 'always'],
    'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
    'class-methods-use-this': 'error',
    'comma-dangle': ['error', 'never'],
    'comma-spacing': ['error', { 'before': false, 'after': true }],
    'comma-style': ['error', 'last'],
    'computed-property-spacing': ['error', 'never'],
    'constructor-super': 'error',
    'curly': 'error',
    'dot-location': ['error', 'property'],
    'eol-last': 'error',
    'eqeqeq': 'error',
    'func-call-spacing': ['error', 'never'],
    'generator-star-spacing': ['error', { 'before': true, 'after': false }],
    'getter-return': 'error',
    'handle-callback-err': ['error', '^(err|error)$' ],
    'indent': ['error', 2, { 'SwitchCase': 1 }],
    'key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
    'keyword-spacing': ['error', { 'before': true, 'after': true }],
    'new-cap': ['error', { 'newIsCap': true, 'capIsNew': false }],
    'new-parens': 'error',
    'no-array-constructor': 'error',
    'no-async-promise-executor': 'error',
    'no-buffer-constructor': 'error',
    'no-caller': 'error',
    'no-class-assign': 'error',
    'no-compare-neg-zero': 'error',
    'no-cond-assign': 'error',
    'no-confusing-arrow': 'error',
    'no-const-assign': 'error',
    'no-constant-condition': 'error',
    'no-control-regex': 'error',
    'no-debugger': 'error',
    'no-delete-var': 'error',
    'no-dupe-args': 'error',
    'no-dupe-class-members': 'error',
    'no-dupe-keys': 'error',
    'no-duplicate-case': 'error',
    'no-duplicate-imports': 'error',
    'no-empty-character-class': 'error',
    'no-empty-pattern': 'error',
    'no-eval': 'error',
    'no-ex-assign': 'error',
    'no-extend-native': 'error',
    'no-extra-bind': 'error',
    'no-extra-boolean-cast': 'error',
    'no-extra-parens': ['error', 'functions'],
    'no-extra-semi': 'error',
    'no-fallthrough': 'error',
    'no-floating-decimal': 'error',
    'no-func-assign': 'error',
    'no-global-assign': 'error',
    'no-implied-eval': 'error',
    'no-inner-declarations': ['error', 'functions'],
    'no-invalid-regexp': 'error',
    'no-irregular-whitespace': 'error',
    'no-iterator': 'error',
    'no-label-var': 'error',
    'no-labels': ['error', { 'allowLoop': true, 'allowSwitch': true }],
    'no-lone-blocks': 'error',
    'no-misleading-character-class': 'error',
    'no-mixed-spaces-and-tabs': 'error',
    'no-multi-spaces': ['error', { 'ignoreEOLComments': true }],
    'no-multi-str': 'error',
    'no-multiple-empty-lines': ['error', { 'max': 2 }],
    'no-new': 'error',
    'no-new-func': 'error',
    'no-new-object': 'error',
    'no-new-symbol': 'error',
    'no-new-require': 'error',
    'no-new-wrappers': 'error',
    'no-obj-calls': 'error',
    'no-octal': 'error',
    'no-octal-escape': 'error',
    'no-proto': 'error',
    'no-redeclare': 'error',
    'no-regex-spaces': 'error',
    'no-return-assign': 'error',
    'no-return-await': 'error',
    'no-self-assign': 'error',
    'no-self-compare': 'error',
    'no-sequences': 'error',
    'no-shadow-restricted-names': 'error',
    'no-sparse-arrays': 'error',
    'no-this-before-super': 'error',
    'no-throw-literal': 'error',
    'no-trailing-spaces': 'error',
    'no-var': 'error',
    'no-undef': 'error',
    'no-undef-init': 'error',
    'no-unexpected-multiline': 'error',
    'no-unneeded-ternary': ['error', { 'defaultAssignment': false }],
    'no-unreachable': 'error',
    'no-unsafe-finally': 'error',
    'no-unsafe-negation': 'error',
    'no-unused-vars': ['error', { 'vars': 'all', 'args': 'none' }],
    'no-use-before-define': ['error', 'nofunc'],
    'no-useless-call': 'error',
    'no-useless-computed-key': 'error',
    'no-useless-constructor': 'error',
    'no-useless-escape': 'error',
    'no-useless-return': 'error',
    'no-whitespace-before-property': 'error',
    'no-with': 'error',
    'object-curly-spacing': ['error', 'always'],
    'object-property-newline': ['error', { 'allowMultiplePropertiesPerLine': true }],
    'one-var': ['error', 'never'],
    'one-var-declaration-per-line': ['error', 'always'],
    'operator-linebreak': ['error', 'after'],
    'padded-blocks': ['error', 'never'],
    'prefer-const': 'error',
    'prefer-numeric-literals': 'error',
    'prefer-rest-params': 'error',
    'prefer-spread': 'error',
    'quotes': ['error', 'single', 'avoid-escape'],
    'radix': 'error',
    'require-atomic-updates': 'error',
    'require-await': 'error',
    'rest-spread-spacing': ['error', 'never'],
    'semi': ['error', 'always'],
    'semi-spacing': ['error', { 'before': false, 'after': true }],
    'space-before-blocks': ['error', 'always'],
    'space-before-function-paren': ['error', 'always'],
    'space-in-parens': ['error', 'never'],
    'space-infix-ops': 'error',
    'space-unary-ops': ['error', { 'words': true, 'nonwords': false }],
    'spaced-comment': ['error', 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }],
    'strict': ['error', 'global'],
    'switch-colon-spacing': ['error', { 'after': true, 'before': true }],
    'symbol-description': 'error',
    'template-curly-spacing': 'error',
    'unicode-bom': ['error', 'never'],
    'use-isnan': 'error',
    'valid-typeof': 'error',
    'wrap-iife': ['error', 'any'],
    'yield-star-spacing': ['error', 'before'],
    'yoda': ['error', 'never']
  }
};
<commit_msg>enable no-useless-catch rule<commit_after>'use strict';

module.exports = {
  root: true,
  env: {
    browser: false,
    es6: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 2018
  },
  rules: {
    'accessor-pairs': 'error',
    'array-bracket-spacing': ['error', 'never'],
    'arrow-body-style': ['error', 'always'],
    'arrow-parens': ['error', 'always'],
    'arrow-spacing': ['error', { 'before': true, 'after': true }],
    'block-spacing': ['error', 'always'],
    'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
    'class-methods-use-this': 'error',
    'comma-dangle': ['error', 'never'],
    'comma-spacing': ['error', { 'before': false, 'after': true }],
    'comma-style': ['error', 'last'],
    'computed-property-spacing': ['error', 'never'],
    'constructor-super': 'error',
    'curly': 'error',
    'dot-location': ['error', 'property'],
    'eol-last': 'error',
    'eqeqeq': 'error',
    'func-call-spacing': ['error', 'never'],
    'generator-star-spacing': ['error', { 'before': true, 'after': false }],
    'getter-return': 'error',
    'handle-callback-err': ['error', '^(err|error)$' ],
    'indent': ['error', 2, { 'SwitchCase': 1 }],
    'key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
    'keyword-spacing': ['error', { 'before': true, 'after': true }],
    'new-cap': ['error', { 'newIsCap': true, 'capIsNew': false }],
    'new-parens': 'error',
    'no-array-constructor': 'error',
    'no-async-promise-executor': 'error',
    'no-buffer-constructor': 'error',
    'no-caller': 'error',
    'no-class-assign': 'error',
    'no-compare-neg-zero': 'error',
    'no-cond-assign': 'error',
    'no-confusing-arrow': 'error',
    'no-const-assign': 'error',
    'no-constant-condition': 'error',
    'no-control-regex': 'error',
    'no-debugger': 'error',
    'no-delete-var': 'error',
    'no-dupe-args': 'error',
    'no-dupe-class-members': 'error',
    'no-dupe-keys': 'error',
    'no-duplicate-case': 'error',
    'no-duplicate-imports': 'error',
    'no-empty-character-class': 'error',
    'no-empty-pattern': 'error',
    'no-eval': 'error',
    'no-ex-assign': 'error',
    'no-extend-native': 'error',
    'no-extra-bind': 'error',
    'no-extra-boolean-cast': 'error',
    'no-extra-parens': ['error', 'functions'],
    'no-extra-semi': 'error',
    'no-fallthrough': 'error',
    'no-floating-decimal': 'error',
    'no-func-assign': 'error',
    'no-global-assign': 'error',
    'no-implied-eval': 'error',
    'no-inner-declarations': ['error', 'functions'],
    'no-invalid-regexp': 'error',
    'no-irregular-whitespace': 'error',
    'no-iterator': 'error',
    'no-label-var': 'error',
    'no-labels': ['error', { 'allowLoop': true, 'allowSwitch': true }],
    'no-lone-blocks': 'error',
    'no-misleading-character-class': 'error',
    'no-mixed-spaces-and-tabs': 'error',
    'no-multi-spaces': ['error', { 'ignoreEOLComments': true }],
    'no-multi-str': 'error',
    'no-multiple-empty-lines': ['error', { 'max': 2 }],
    'no-new': 'error',
    'no-new-func': 'error',
    'no-new-object': 'error',
    'no-new-symbol': 'error',
    'no-new-require': 'error',
    'no-new-wrappers': 'error',
    'no-obj-calls': 'error',
    'no-octal': 'error',
    'no-octal-escape': 'error',
    'no-proto': 'error',
    'no-redeclare': 'error',
    'no-regex-spaces': 'error',
    'no-return-assign': 'error',
    'no-return-await': 'error',
    'no-self-assign': 'error',
    'no-self-compare': 'error',
    'no-sequences': 'error',
    'no-shadow-restricted-names': 'error',
    'no-sparse-arrays': 'error',
    'no-this-before-super': 'error',
    'no-throw-literal': 'error',
    'no-trailing-spaces': 'error',
    'no-var': 'error',
    'no-undef': 'error',
    'no-undef-init': 'error',
    'no-unexpected-multiline': 'error',
    'no-unneeded-ternary': ['error', { 'defaultAssignment': false }],
    'no-unreachable': 'error',
    'no-unsafe-finally': 'error',
    'no-unsafe-negation': 'error',
    'no-unused-vars': ['error', { 'vars': 'all', 'args': 'none' }],
    'no-use-before-define': ['error', 'nofunc'],
    'no-useless-call': 'error',
    'no-useless-catch': 'error',
    'no-useless-computed-key': 'error',
    'no-useless-constructor': 'error',
    'no-useless-escape': 'error',
    'no-useless-return': 'error',
    'no-whitespace-before-property': 'error',
    'no-with': 'error',
    'object-curly-spacing': ['error', 'always'],
    'object-property-newline': ['error', { 'allowMultiplePropertiesPerLine': true }],
    'one-var': ['error', 'never'],
    'one-var-declaration-per-line': ['error', 'always'],
    'operator-linebreak': ['error', 'after'],
    'padded-blocks': ['error', 'never'],
    'prefer-const': 'error',
    'prefer-numeric-literals': 'error',
    'prefer-rest-params': 'error',
    'prefer-spread': 'error',
    'quotes': ['error', 'single', 'avoid-escape'],
    'radix': 'error',
    'require-atomic-updates': 'error',
    'require-await': 'error',
    'rest-spread-spacing': ['error', 'never'],
    'semi': ['error', 'always'],
    'semi-spacing': ['error', { 'before': false, 'after': true }],
    'space-before-blocks': ['error', 'always'],
    'space-before-function-paren': ['error', 'always'],
    'space-in-parens': ['error', 'never'],
    'space-infix-ops': 'error',
    'space-unary-ops': ['error', { 'words': true, 'nonwords': false }],
    'spaced-comment': ['error', 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }],
    'strict': ['error', 'global'],
    'switch-colon-spacing': ['error', { 'after': true, 'before': true }],
    'symbol-description': 'error',
    'template-curly-spacing': 'error',
    'unicode-bom': ['error', 'never'],
    'use-isnan': 'error',
    'valid-typeof': 'error',
    'wrap-iife': ['error', 'any'],
    'yield-star-spacing': ['error', 'before'],
    'yoda': ['error', 'never']
  }
};
<|endoftext|>


<commit_before>module.exports = {
    'env': {
        'browser': true,
        'commonjs': true,
        'es6': true,
        'jasmine': true
    },
    'extends': [
        'eslint:recommended',
        'plugin:flowtype/recommended'
    ],
    'globals': {
        // The globals that (1) are accessed but not defined within many of our
        // files, (2) are certainly defined, and (3) we would like to use
        // without explicitly specifying them (using a comment) inside of our
        // files.
        '__filename': false
    },
    'parser': 'babel-eslint',
    'parserOptions': {
        'ecmaFeatures': {
            'experimentalObjectRestSpread': true
        },
        'sourceType': 'module'
    },
    'plugins': [
        'flowtype',

        // ESLint's rule no-duplicate-imports does not understand Flow's import
        // type. Fortunately, eslint-plugin-import understands Flow's import
        // type.
        'import'
    ],
    'rules': {
        'new-cap': 2,
        'no-console': 0,
        'semi': [ 'error', 'always' ],

        'no-cond-assign': 2,
        'no-constant-condition': 2,
        'no-control-regex': 2,
        'no-debugger': 2,
        'no-dupe-args': 2,
        'no-duplicate-case': 2,
        'no-empty': 2,
        'no-empty-character-class': 2,
        'no-ex-assign': 2,
        'no-extra-boolean-cast': 2,
        'no-extra-parens': [
            'error',
            'all',
            { 'nestedBinaryExpressions': false }
        ],

        'rest-spread-spacing': 2,
        'sort-imports': 0,
        'template-curly-spacing': 2,
        'yield-star-spacing': 2,

        'import/no-duplicates': 2
    }
};
<commit_msg>[eslint] require-yield<commit_after>module.exports = {
    'env': {
        'browser': true,
        'commonjs': true,
        'es6': true,
        'jasmine': true
    },
    'extends': [
        'eslint:recommended',
        'plugin:flowtype/recommended'
    ],
    'globals': {
        // The globals that (1) are accessed but not defined within many of our
        // files, (2) are certainly defined, and (3) we would like to use
        // without explicitly specifying them (using a comment) inside of our
        // files.
        '__filename': false
    },
    'parser': 'babel-eslint',
    'parserOptions': {
        'ecmaFeatures': {
            'experimentalObjectRestSpread': true
        },
        'sourceType': 'module'
    },
    'plugins': [
        'flowtype',

        // ESLint's rule no-duplicate-imports does not understand Flow's import
        // type. Fortunately, eslint-plugin-import understands Flow's import
        // type.
        'import'
    ],
    'rules': {
        'new-cap': 2,
        'no-console': 0,
        'semi': [ 'error', 'always' ],

        'no-cond-assign': 2,
        'no-constant-condition': 2,
        'no-control-regex': 2,
        'no-debugger': 2,
        'no-dupe-args': 2,
        'no-duplicate-case': 2,
        'no-empty': 2,
        'no-empty-character-class': 2,
        'no-ex-assign': 2,
        'no-extra-boolean-cast': 2,
        'no-extra-parens': [
            'error',
            'all',
            { 'nestedBinaryExpressions': false }
        ],

        'require-yield': 2,
        'rest-spread-spacing': 2,
        'sort-imports': 0,
        'template-curly-spacing': 2,
        'yield-star-spacing': 2,

        'import/no-duplicates': 2
    }
};
<|endoftext|>


<commit_before>module.exports = {
  // extending prettier fucks up my vim...
  extends: ['airbnb-base'],
  parser: 'typescript-eslint-parser',
  plugins: ['typescript', 'import'],
  rules: {
    'class-methods-use-this': 0,
    'comma-dangle': [
      'error',
      {
        arrays: 'only-multiline',
        objects: 'only-multiline',
        imports: 'only-multiline',
        exports: 'only-multiline',
        functions: 'ignore',
      },
    ],
    'no-underscore-dangle': 0,
    'no-mixed-operators': 0,
    'func-names': 0,

    // prettier things
    'arrow-parens': 0,
    'space-before-function-paren': 0,

    'import/extensions': 0,
  },

  settings: {
    'import/parsers': {
      'typescript-eslint-parser': ['.ts', '.tsx'],
    },
  },
};
<commit_msg>Fix some eslint import rules<commit_after>module.exports = {
  // extending prettier fucks up my vim...
  extends: ['airbnb-base'],
  parser: 'typescript-eslint-parser',
  plugins: ['typescript', 'import'],
  rules: {
    'class-methods-use-this': 0,
    'comma-dangle': [
      'error',
      {
        arrays: 'only-multiline',
        objects: 'only-multiline',
        imports: 'only-multiline',
        exports: 'only-multiline',
        functions: 'ignore',
      },
    ],
    'no-underscore-dangle': 0,
    'no-mixed-operators': 0,
    'func-names': 0,

    // prettier things
    'arrow-parens': 0,
    'space-before-function-paren': 0,

    'import/extensions': 0,
    'import/prefer-default-export': 0,
  },

  settings: {
    'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts'] } },
    'import/parsers': {
      'typescript-eslint-parser': ['.ts', '.tsx'],
    },
  },
};
<|endoftext|>


<commit_before>module.exports = {
  'parserOptions': {
    'ecmaVersion': 6,
    'sourceType': 'module',
    'ecmaFeatures': {
      'jsx': true,
    }
  },

  'plugins': [
    'react',
    'import',
  ],

  'extends': [
    'eslint:recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/react',
    'plugin:react/recommended',
    'airbnb',
  ],

  'settings': {
    'import/resolver': 'webpack',
  },

  'rules': {
    'import/extensions': [2, 'never'],
  },

};
<commit_msg>fix(eslint): add import/resolver node to resolve webpack.config.js<commit_after>module.exports = {
  'parserOptions': {
    'ecmaVersion': 6,
    'sourceType': 'module',
    'ecmaFeatures': {
      'jsx': true,
    }
  },

  'plugins': [
    'react',
    'import',
  ],

  'extends': [
    'eslint:recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/react',
    'plugin:react/recommended',
    'airbnb',
  ],

  'settings': {
    'import/resolver': ['node', 'webpack'],
  },

  'rules': {
    'import/extensions': [2, 'never'],
  },

};
<|endoftext|>


<commit_before>/**
 * to set content editable need to add attribute contenteditable="true" or contenteditable
 * example: <input class="custom_select__placeholder" type="text" contenteditable="true">
 */
(function($){
jQuery.fn.customSelect = function(options ) {

    var defaults = {},
        settings = $.extend({}, defaults, options);

    function isEditableInput ( $node ) {
        var isNodeEditable = false;
        $.each( $node[0].attributes, function ( index, attribute ) {
            if ( attribute.name === "contenteditable" ) {
                isNodeEditable = true ;
                return false; //to break this loop
            }
        });
        return isNodeEditable;
    }

    function setEditable(input) {
        if( input.attr("contentEditable") || isEditableInput( input ) ) {
            input.removeAttr( "readonly" );
            addNumberPattern(input);
        }
    }
    function addNumberPattern($node) {
        if ($node.attr('type') === 'number'){
            $node.attr('pattern','[0-9]*');
            $node.attr( 'inputmode', 'numeric' );
        }
    }

    return this.each(function () {

        var $custom_select = $(this);
        $custom_select.append('
');

        var $select = $custom_select.find('select'),
            $placeholder = $custom_select.find('input'),
            $list = $custom_select.find('ul'),
            $feedbackModal = $('#feedback-modal'),
            openedCssClass = 'custom_select-opened',
            activeItemCssClass = 'custom_select__item-active',
            speed = 300;

        function show() {
            $list.slideDown(speed);
            $custom_select.addClass(openedCssClass);
            $placeholder.focus();
        }

        function hide() {
            $list.slideUp(speed);
            $custom_select.removeClass(openedCssClass);
        }

        function set(self, isInit) {
            var $self = $(self);
            $placeholder.val($self.text());
            $select.val($self.data('value'));
            if(!isInit) $select.trigger('change');
            $list.find('li').removeClass(activeItemCssClass);
            $self.addClass(activeItemCssClass);
        }

        function toggle() {
            if(!$select.is(':disabled')){
                if ($list.is(':visible')) hide();
                else show();
            }
        }

        function blur() {
            setTimeout(hide, 100);
        }

        function reset() {
            set($list.find('li').filter(':first'), true);
        }

        function setValueByKeyboard() {
            var newValue = $placeholder.val();
            if (newValue === ''){ $list.find('li:first').trigger('click'); return false; }
            $placeholder.attr( "value", newValue );
            $list.append( $('
'+newValue+'
') );
            $select.append($('<option>', {value: newValue, text: newValue }));
            $list.find('li:last').trigger('click');
        }

        // function selectOption() {
        //     $("#autofill").val($(".selected a").text());
        //     $(".services").hide();
        // }

        // Events
        $list.on('click', 'li', function(){
            set(this, false);
        });
        $placeholder.on('blur', blur);

        if ( isEditableInput($placeholder) ) $custom_select.on('change', 'input', setValueByKeyboard);

        $custom_select.on({
            'click': toggle,
            'custom-reset': reset
        }).keydown(function( e ) {
            console.log('keypress Enter',e.which , e.keyCode);
            if ( e.which == 13 ) {
                e.preventDefault();
                if ($(".custom_select__list ").is(":visible")) {
                    set($('.custom_select__item-active',this), false);
                    toggle();
                } else {
                    toggle();
                }
            }
            if (e.which == 38) { // up
                e.preventDefault();
                var selected = $(".custom_select__item-active");
                $(".custom_select__list li").removeClass("custom_select__item-active");
                if (selected.prev().length == 0) {
                    selected.siblings().last().addClass("custom_select__item-active");
                } else {
                    selected.prev().addClass("custom_select__item-active");
                }
            }
            if (e.which == 40) { // down
                e.preventDefault();
                var selected = $(".custom_select__item-active");
                $(".custom_select__list li").removeClass("custom_select__item-active");
                if (selected.next().length == 0) {
                    selected.siblings().first().addClass("custom_select__item-active");
                } else {
                    selected.next().addClass("custom_select__item-active");
                }
            }
        });
        $feedbackModal.on({
            'hide.bs.modal': reset,
            'show.bs.modal': reset
        });

        setEditable($placeholder);

        reset();
        });
    };
})(jQuery);

$(document).on('ready', function () {
    $('.js_custom_select').customSelect();
});
<commit_msg>mod: ckeck if val has selector<commit_after>/**
 * to set content editable need to add attribute contenteditable="true" or contenteditable
 * example: <input class="custom_select__placeholder" type="text" contenteditable="true">
 */
(function($){
jQuery.fn.customSelect = function(options ) {

    var defaults = {},
        settings = $.extend({}, defaults, options);

    function isEditableInput ( $node ) {
        var isNodeEditable = false;
        $.each( $node[0].attributes, function ( index, attribute ) {
            if ( attribute.name === "contenteditable" ) {
                isNodeEditable = true ;
                return false; //to break this loop
            }
        });
        return isNodeEditable;
    }

    function setEditable(input) {
        if( input.attr("contentEditable") || isEditableInput( input ) ) {
            input.removeAttr( "readonly" );
            addNumberPattern(input);
        }
    }
    function addNumberPattern($node) {
        if ($node.attr('type') === 'number'){
            $node.attr('pattern','[0-9]*');
            $node.attr( 'inputmode', 'numeric' );
        }
    }

    return this.each(function () {

        var $custom_select = $(this);
        $custom_select.append('
');

        var $select = $custom_select.find('select'),
            $placeholder = $custom_select.find('input'),
            $list = $custom_select.find('ul'),
            $feedbackModal = $('#feedback-modal'),
            openedCssClass = 'custom_select-opened',
            activeItemCssClass = 'custom_select__item-active',
            speed = 300;

        function show() {
            $list.slideDown(speed);
            $custom_select.addClass(openedCssClass);
            $placeholder.focus();
        }

        function hide() {
            $list.slideUp(speed);
            $custom_select.removeClass(openedCssClass);
        }

        function set(self, isInit) {
            var $self = $(self);
            $placeholder.val($self.text());
            $select.val($self.data('value'));
            if(!isInit) $select.trigger('change');
            $list.find('li').removeClass(activeItemCssClass);
            $self.addClass(activeItemCssClass);
        }

        function toggle() {
            if(!$select.is(':disabled')){
                if ($list.is(':visible')) hide();
                else show();
            }
        }

        function blur() {
            setTimeout(hide, 100);
        }

        function reset() {
            set($list.find('li').filter(':first'), true);
        }

        function setValueByKeyboard() {
            var newValue = $placeholder.val();
            if (newValue === ''){ $list.find('li:first').trigger('click'); return false; }
            $placeholder.attr( "value", newValue );
            $list.append( $('
'+newValue+'
') );
            $select.append($('<option>', {value: newValue, text: newValue }));
            $list.find('li:last').trigger('click');
        }

        function keyboardListener(e) {
            function setSelector(list ,me){
                $.each(list, function(i, el) {
                    if ($.inArray(el) == -1){
                        if( $(el).data('value') !== $placeholder.val() ) {
                            selected = $(".custom_select__item",me).eq(i);
                        }
                    }
                    else {
                        console.info('error' , i, el );
                    }
                });
              return list;
            }

            if ( e.which == 13 ) {
                e.preventDefault();
                if ($(".custom_select__list ").is(":visible")) {
                    set($('.custom_select__item-active',$(this) ), false);
                    toggle();
                } else {
                    toggle();
                }
            }
            if (e.which == 38) { // up
                e.preventDefault();
                var selected = $(".custom_select__item-active", $(this , 'ul') );
                if(selected.length < 1){
                    selected = setSelector($(".custom_select__item",this) ,this);
                }
                $(".custom_select__list li").removeClass("custom_select__item-active");
                if (selected.prev().length == 0) {
                    selected.siblings().last().addClass("custom_select__item-active");
                } else {
                    selected.prev().addClass("custom_select__item-active");
                }
            }
            if (e.which == 40) { // down
                e.preventDefault();
                var selected = $(".custom_select__item-active",  $(this , 'ul'));
                if(selected.length < 1){
                    selected = setSelector($(".custom_select__item",this),this);
                }
                $(".custom_select__list li").removeClass("custom_select__item-active");
                if (selected.next().length == 0) {
                    selected.siblings().first().addClass("custom_select__item-active");
                } else {
                    selected.next().addClass("custom_select__item-active");
                }
            }
        }

        // Events
        $list.on('click', 'li', function(){
            set(this, false);
        });
        $placeholder.on('blur', blur);

        if ( isEditableInput($placeholder) ) $custom_select.on('change', 'input', setValueByKeyboard);

        $custom_select.on({
            'click': toggle,
            'custom-reset': reset,
            'keydown' : keyboardListener
        });
        $feedbackModal.on({
            'hide.bs.modal': reset,
            'show.bs.modal': reset
        });

        setEditable($placeholder);

        reset();
        });
    };
})(jQuery);

$(document).on('ready', function () {
    $('.js_custom_select').customSelect();
});
<|endoftext|>


<commit_before>/**
 * @fileoverview The bulk of the Performance page of CT.
 */

import 'elements-sk/icon/delete-icon-sk';
import 'elements-sk/icon/cancel-icon-sk';
import 'elements-sk/icon/check-circle-icon-sk';
import 'elements-sk/icon/help-icon-sk';
import 'elements-sk/toast-sk';
import '../../../infra-sk/modules/confirm-dialog-sk';
import '../suggest-input-sk';
import '../input-sk';
import '../patch-sk';
import '../pageset-selector-sk';
import '../task-repeater-sk';
import '../task-priority-sk';

import { $$, $ } from 'common-sk/modules/dom';
import { define } from 'elements-sk/define';
import 'elements-sk/select-sk';
import { errorMessage } from 'elements-sk/errorMessage';
import { html } from 'lit-html';

import { ElementSk } from '../../../infra-sk/modules/ElementSk';
import {
  combineClDescriptions,
  missingLiveSitesWithCustomWebpages,
  moreThanThreeActiveTasksChecker,
  fetchBenchmarksAndPlatforms,
} from '../ctfe_utils';

// Chromium perf doesn't support 1M and 100K pagesets.
const unsupportedPageSetStrings = ['All', '100k'];

const template = (el) => html`
<confirm-dialog-sk id=confirm_dialog></confirm-dialog-sk>

    Benchmark Name

      <suggest-input-sk
        id=benchmark_name
        .options=${el._benchmarks}
        .label=${'Hit <enter> at end if entering custom benchmark'}
        accept-custom-value
        @value-changed=${el._refreshBenchmarkDoc}
      ></suggest-input-sk>

          Documentation

    Target Platform

      <select-sk id=platform_selector @selection-changed=${el._platformChanged}>
        ${el._platforms.map((p, i) => (html`<div ?selected=${i === 1}>${p[1]}</div>`))}
      </select-sk>

    PagestSets Type

      <pageset-selector-sk id=pageset_selector
        .hideIfKeyContains=${unsupportedPageSetStrings}>
      </pageset-selector-sk>

      Run in Parallel

      Read about the trade-offs here

      <select-sk id=run_in_parallel>

True

False

      </select-sk>

    Benchmark Arguments

      <input-sk value="--output-format=csv --pageset-repeat=1 --skip-typ-expectations-tags-validation --legacy-json-trace-format" id=benchmark_args class=long-field></input-sk>
      Note: Change the --pageset-repeat value if you would like lower/higher repeats of each web page. 1 is the default.

      Note: Use --run-benchmark-timeout=[secs] to specify the timeout of the run_benchmark script. 300 is the default.

      Note: Use --max-pages-per-bot=[num] to specify the number of pages to run per bot. 100 is the default.

    Browser Arguments (nopatch run)

      <input-sk value="" id=browser_args_nopatch class=long-field></input-sk>

    Browser Arguments (withpatch run)

      <input-sk value="" id=browser_args_withpatch class=long-field></input-sk>

    Field Value Column Name

      <input-sk value="avg" id=value_column_name class="medium-field"></input-sk>
      Which column's entries to use as field values.

      Chromium Git patch (optional)

      Applied to Chromium ToT

      or to the hash specified below.

      <patch-sk id=chromium_patch
                patchType=chromium
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Skia Git patch (optional)

      Applied to Skia Rev in DEPS

      <patch-sk id=skia_patch
                patchType=skia
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      V8 Git patch (optional)

      Applied to V8 Rev in DEPS

      <patch-sk id=v8_patch
                patchType=v8
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Catapult Git patch (optional)

      Applied to Catapult Rev in DEPS

      <patch-sk id=catapult_patch
                patchType=catapult
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Chromium Git metrics patch (optional)

      Applied to Chromium ToT

      or to the hash specified below.

      Used to create the base build (See skbug/9029)

      <patch-sk id=chromium_patch_base_build
                patchType=chromium
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

    Chromium hash to sync to (optional)

      <input-sk value="" id=chromium_hash class=long-field></input-sk>

    Repeat this task

      <task-repeater-sk id=repeat_after_days></task-repeater-sk>

    Task Priority

      <task-priority-sk id=task_priority></task-priority-sk>

      Notifications CC list (optional)

      Email will be sent by ct@skia.org

      <input-sk value="" id=cc_list label="email1,email2,email3" class=long-field></input-sk>

      Group name (optional)

      Will be used to track runs

      <input-sk value="" id=group_name class=long-field></input-sk>

    Description

      <input-sk value="" id=description label="Description is required" class=long-field></input-sk>

        <spinner-sk .active=${el._triggeringTask} alt="Trigger task"></spinner-sk>

      <button  id=submit ?disabled=${el._triggeringTask} @click=${el._validateTask}>Queue Task</button>

      <button id=view_history>View runs history</button>

`;

define('chromium-perf-sk', class extends ElementSk {
  constructor() {
    super(template);
    this._benchmarksToDocs = {};
    this._benchmarks = [];
    this._platforms = [];
    this._triggeringTask = false;
    this._moreThanThreeActiveTasks = moreThanThreeActiveTasksChecker();
  }

  connectedCallback() {
    super.connectedCallback();
    this._render();
    fetchBenchmarksAndPlatforms((json) => {
      this._benchmarksToDocs = json.benchmarks;
      this._benchmarks = Object.keys(json.benchmarks);
      // { 'p1' : 'p1Desc', ... } -> [[p1, p1Desc], ...]
      // Allows rendering descriptions in the select-sk, and converting the
      // integer selection to platform name easily.
      this._platforms = Object.entries(json.platforms);
      this._render();
    });
  }

  _refreshBenchmarkDoc(e) {
    const benchmarkName = e.detail.value;
    const docElement = $$('#benchmark_doc', this);
    if (benchmarkName && this._benchmarksToDocs[benchmarkName]) {
      docElement.hidden = false;
      docElement.href = this._benchmarksToDocs[benchmarkName];
    } else {
      docElement.hidden = true;
      docElement.href = '#';
    }
  }

  _platformChanged(e) {
    const pagesetSelector = $$('pageset-selector-sk', this);
    if (e.detail.selection === 0) {
      pagesetSelector.selected = 'Mobile10k';
    } else {
      pagesetSelector.selected = '10k';
    }
  }

  _patchChanged() {
    $$('#description', this).value = combineClDescriptions(
      $('patch-sk', this).map((patch) => patch.clDescription),
    );
  }

  _validateTask() {
    if (!$('patch-sk', this).every((patch) => patch.validate())) {
      return;
    }
    if (!$$('#description', this).value) {
      errorMessage('Please specify a description');
      $$('#description', this).focus();
      return;
    }
    if (!$$('#benchmark_name', this).value) {
      errorMessage('Please specify a benchmark');
      $$('#benchmark_name', this).focus();
      return;
    }
    if (missingLiveSitesWithCustomWebpages(
      $$('#pageset_selector', this).customPages, $$('#benchmark_args', this).value,
    )) {
      $$('#benchmark_args', this).focus();
      return;
    }
    if (this._moreThanThreeActiveTasks()) {
      return;
    }
    $$('#confirm_dialog', this).open('Proceed with queueing task?')
      .then(() => this._queueTask())
      .catch(() => {
        errorMessage('Unable to queue task');
      });
  }

  _queueTask() {
    this._triggeringTask = true;
    const params = {};
    params.benchmark = $$('#benchmark_name', this).value;
    params.platform = this._platforms[$$('#platform_selector', this).selection][0];
    params.page_sets = $$('#pageset_selector', this).selected;
    params.custom_webpages = $$('#pageset_selector', this).customPages;
    params.repeat_runs = this._getRepeatValue();
    params.run_in_parallel = ['True', 'False'][$$('#run_in_parallel', this).selection];
    params.benchmark_args = $$('#benchmark_args', this).value;
    params.browser_args_nopatch = $$('#browser_args_nopatch', this).value;
    params.browser_args_withpatch = $$('#browser_args_withpatch', this).value;
    params.value_column_name = $$('#value_column_name', this).value;
    params.desc = $$('#description', this).value;
    params.chromium_patch = $$('#chromium_patch', this).patch;
    params.skia_patch = $$('#skia_patch', this).patch;
    params.v8_patch = $$('#v8_patch', this).patch;
    params.catapult_patch = $$('#catapult_patch', this).patch;
    params.chromium_patch_base_build = $$('#chromium_patch_base_build', this).patch;
    params.chromium_hash = $$('#chromium_hash', this).value;
    params.repeat_after_days = $$('#repeat_after_days', this).frequency;
    params.task_priority = $$('#task_priority', this).priority;
    // Run on GCE if it is Windows. This will change in the future if we
    // get bare-metal Win machines.
    params.run_on_gce = ($$('#platform_selector', this).selection === 'Windows').toString();
    if ($$('#cc_list', this).value) {
      params.cc_list = $$('#cc_list', this).value.split(',');
    }
    if ($$('#group_name', this).value) {
      params.group_name = $$('#group_name', this).value;
    }

    fetch('/_/add_chromium_perf_task', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(params),
    })
      .then(() => this._gotoRunsHistory())
      .catch((e) => {
        this._triggeringTask = false;
        errorMessage(e);
      });
  }

  _getRepeatValue() {
    // If "--pageset-repeat" is specified in benchmark args then use that
    // value else use "1".
    const rx = /--pageset-repeat[ =](\d+)/gm;
    const m = rx.exec($$('#benchmark_args', this).value);
    if (m) {
      return m[1];
    }
    return '1';
  }

  _gotoRunsHistory() {
    window.location.href = '/chromium_perf_runs/';
  }
});
<commit_msg>[ct] Fix missing handler for Runs History in chromium-perf-sk<commit_after>/**
 * @fileoverview The bulk of the Performance page of CT.
 */

import 'elements-sk/icon/delete-icon-sk';
import 'elements-sk/icon/cancel-icon-sk';
import 'elements-sk/icon/check-circle-icon-sk';
import 'elements-sk/icon/help-icon-sk';
import 'elements-sk/toast-sk';
import '../../../infra-sk/modules/confirm-dialog-sk';
import '../suggest-input-sk';
import '../input-sk';
import '../patch-sk';
import '../pageset-selector-sk';
import '../task-repeater-sk';
import '../task-priority-sk';

import { $$, $ } from 'common-sk/modules/dom';
import { define } from 'elements-sk/define';
import 'elements-sk/select-sk';
import { errorMessage } from 'elements-sk/errorMessage';
import { html } from 'lit-html';

import { ElementSk } from '../../../infra-sk/modules/ElementSk';
import {
  combineClDescriptions,
  missingLiveSitesWithCustomWebpages,
  moreThanThreeActiveTasksChecker,
  fetchBenchmarksAndPlatforms,
} from '../ctfe_utils';

// Chromium perf doesn't support 1M and 100K pagesets.
const unsupportedPageSetStrings = ['All', '100k'];

const template = (el) => html`
<confirm-dialog-sk id=confirm_dialog></confirm-dialog-sk>

    Benchmark Name

      <suggest-input-sk
        id=benchmark_name
        .options=${el._benchmarks}
        .label=${'Hit <enter> at end if entering custom benchmark'}
        accept-custom-value
        @value-changed=${el._refreshBenchmarkDoc}
      ></suggest-input-sk>

          Documentation

    Target Platform

      <select-sk id=platform_selector @selection-changed=${el._platformChanged}>
        ${el._platforms.map((p, i) => (html`<div ?selected=${i === 1}>${p[1]}</div>`))}
      </select-sk>

    PagestSets Type

      <pageset-selector-sk id=pageset_selector
        .hideIfKeyContains=${unsupportedPageSetStrings}>
      </pageset-selector-sk>

      Run in Parallel

      Read about the trade-offs here

      <select-sk id=run_in_parallel>

True

False

      </select-sk>

    Benchmark Arguments

      <input-sk value="--output-format=csv --pageset-repeat=1 --skip-typ-expectations-tags-validation --legacy-json-trace-format" id=benchmark_args class=long-field></input-sk>
      Note: Change the --pageset-repeat value if you would like lower/higher repeats of each web page. 1 is the default.

      Note: Use --run-benchmark-timeout=[secs] to specify the timeout of the run_benchmark script. 300 is the default.

      Note: Use --max-pages-per-bot=[num] to specify the number of pages to run per bot. 100 is the default.

    Browser Arguments (nopatch run)

      <input-sk value="" id=browser_args_nopatch class=long-field></input-sk>

    Browser Arguments (withpatch run)

      <input-sk value="" id=browser_args_withpatch class=long-field></input-sk>

    Field Value Column Name

      <input-sk value="avg" id=value_column_name class="medium-field"></input-sk>
      Which column's entries to use as field values.

      Chromium Git patch (optional)

      Applied to Chromium ToT

      or to the hash specified below.

      <patch-sk id=chromium_patch
                patchType=chromium
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Skia Git patch (optional)

      Applied to Skia Rev in DEPS

      <patch-sk id=skia_patch
                patchType=skia
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      V8 Git patch (optional)

      Applied to V8 Rev in DEPS

      <patch-sk id=v8_patch
                patchType=v8
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Catapult Git patch (optional)

      Applied to Catapult Rev in DEPS

      <patch-sk id=catapult_patch
                patchType=catapult
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

      Chromium Git metrics patch (optional)

      Applied to Chromium ToT

      or to the hash specified below.

      Used to create the base build (See skbug/9029)

      <patch-sk id=chromium_patch_base_build
                patchType=chromium
                @cl-description-changed=${el._patchChanged}>
      </patch-sk>

    Chromium hash to sync to (optional)

      <input-sk value="" id=chromium_hash class=long-field></input-sk>

    Repeat this task

      <task-repeater-sk id=repeat_after_days></task-repeater-sk>

    Task Priority

      <task-priority-sk id=task_priority></task-priority-sk>

      Notifications CC list (optional)

      Email will be sent by ct@skia.org

      <input-sk value="" id=cc_list label="email1,email2,email3" class=long-field></input-sk>

      Group name (optional)

      Will be used to track runs

      <input-sk value="" id=group_name class=long-field></input-sk>

    Description

      <input-sk value="" id=description label="Description is required" class=long-field></input-sk>

        <spinner-sk .active=${el._triggeringTask} alt="Trigger task"></spinner-sk>

      <button  id=submit ?disabled=${el._triggeringTask} @click=${el._validateTask}>Queue Task</button>

      <button id=view_history @click=${el._gotoRunsHistory}>View runs history</button>

`;

define('chromium-perf-sk', class extends ElementSk {
  constructor() {
    super(template);
    this._benchmarksToDocs = {};
    this._benchmarks = [];
    this._platforms = [];
    this._triggeringTask = false;
    this._moreThanThreeActiveTasks = moreThanThreeActiveTasksChecker();
  }

  connectedCallback() {
    super.connectedCallback();
    this._render();
    fetchBenchmarksAndPlatforms((json) => {
      this._benchmarksToDocs = json.benchmarks;
      this._benchmarks = Object.keys(json.benchmarks);
      // { 'p1' : 'p1Desc', ... } -> [[p1, p1Desc], ...]
      // Allows rendering descriptions in the select-sk, and converting the
      // integer selection to platform name easily.
      this._platforms = Object.entries(json.platforms);
      this._render();
    });
  }

  _refreshBenchmarkDoc(e) {
    const benchmarkName = e.detail.value;
    const docElement = $$('#benchmark_doc', this);
    if (benchmarkName && this._benchmarksToDocs[benchmarkName]) {
      docElement.hidden = false;
      docElement.href = this._benchmarksToDocs[benchmarkName];
    } else {
      docElement.hidden = true;
      docElement.href = '#';
    }
  }

  _platformChanged(e) {
    const pagesetSelector = $$('pageset-selector-sk', this);
    if (e.detail.selection === 0) {
      pagesetSelector.selected = 'Mobile10k';
    } else {
      pagesetSelector.selected = '10k';
    }
  }

  _patchChanged() {
    $$('#description', this).value = combineClDescriptions(
      $('patch-sk', this).map((patch) => patch.clDescription),
    );
  }

  _validateTask() {
    if (!$('patch-sk', this).every((patch) => patch.validate())) {
      return;
    }
    if (!$$('#description', this).value) {
      errorMessage('Please specify a description');
      $$('#description', this).focus();
      return;
    }
    if (!$$('#benchmark_name', this).value) {
      errorMessage('Please specify a benchmark');
      $$('#benchmark_name', this).focus();
      return;
    }
    if (missingLiveSitesWithCustomWebpages(
      $$('#pageset_selector', this).customPages, $$('#benchmark_args', this).value,
    )) {
      $$('#benchmark_args', this).focus();
      return;
    }
    if (this._moreThanThreeActiveTasks()) {
      return;
    }
    $$('#confirm_dialog', this).open('Proceed with queueing task?')
      .then(() => this._queueTask())
      .catch(() => {
        errorMessage('Unable to queue task');
      });
  }

  _queueTask() {
    this._triggeringTask = true;
    const params = {};
    params.benchmark = $$('#benchmark_name', this).value;
    params.platform = this._platforms[$$('#platform_selector', this).selection][0];
    params.page_sets = $$('#pageset_selector', this).selected;
    params.custom_webpages = $$('#pageset_selector', this).customPages;
    params.repeat_runs = this._getRepeatValue();
    params.run_in_parallel = ['True', 'False'][$$('#run_in_parallel', this).selection];
    params.benchmark_args = $$('#benchmark_args', this).value;
    params.browser_args_nopatch = $$('#browser_args_nopatch', this).value;
    params.browser_args_withpatch = $$('#browser_args_withpatch', this).value;
    params.value_column_name = $$('#value_column_name', this).value;
    params.desc = $$('#description', this).value;
    params.chromium_patch = $$('#chromium_patch', this).patch;
    params.skia_patch = $$('#skia_patch', this).patch;
    params.v8_patch = $$('#v8_patch', this).patch;
    params.catapult_patch = $$('#catapult_patch', this).patch;
    params.chromium_patch_base_build = $$('#chromium_patch_base_build', this).patch;
    params.chromium_hash = $$('#chromium_hash', this).value;
    params.repeat_after_days = $$('#repeat_after_days', this).frequency;
    params.task_priority = $$('#task_priority', this).priority;
    // Run on GCE if it is Windows. This will change in the future if we
    // get bare-metal Win machines.
    params.run_on_gce = ($$('#platform_selector', this).selection === 'Windows').toString();
    if ($$('#cc_list', this).value) {
      params.cc_list = $$('#cc_list', this).value.split(',');
    }
    if ($$('#group_name', this).value) {
      params.group_name = $$('#group_name', this).value;
    }

    fetch('/_/add_chromium_perf_task', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(params),
    })
      .then(() => this._gotoRunsHistory())
      .catch((e) => {
        this._triggeringTask = false;
        errorMessage(e);
      });
  }

  _getRepeatValue() {
    // If "--pageset-repeat" is specified in benchmark args then use that
    // value else use "1".
    const rx = /--pageset-repeat[ =](\d+)/gm;
    const m = rx.exec($$('#benchmark_args', this).value);
    if (m) {
      return m[1];
    }
    return '1';
  }

  _gotoRunsHistory() {
    window.location.href = '/chromium_perf_runs/';
  }
});
<|endoftext|>