<commit_before>define(['sprd/entity/Configuration', 'sprd/entity/Size', 'sprd/util/UnitUtil', 'sprd/model/Design', "sprd/entity/PrintTypeColor", "underscore", "sprd/model/PrintType", "sprd/util/ProductUtil", "js/core/List", "flow"], function (Configuration, Size, UnitUtil, Design, PrintTypeColor, _, PrintType, ProductUtil, List, flow) {

    var undefined;

    return Configuration.inherit('sprd.model.DesignConfiguration', {

        schema: {
            type: String,
            content: Object,
            design: Design,
            restrictions: Object
        },

        defaults: {
            type: 'design',
            _dpi: "{printType.dpi}",

            design: null,

            _designCommission: "{design.price}"
        },

        ctor: function () {
            this.$sizeCache = {};
            this.$$ = {};
            this.callBase();
        },

        _commitPrintType: function (printType) {
            if (!this.$entityInitialized) {
                return;
            }
            // print type changed -> convert colors

            if (!printType || !printType.get('restrictions.colorSpace')) {
                return;
            }

            var colors = [],
                printColors = this.$.printColors;

            printColors.each(function (printColor) {
                colors.push(printType.getClosestPrintColor(printColor.color()));
            });

            if (printType.$.id === PrintType.Mapping.SpecialFlex) {
                // convert all colors to the first one
                for (var i = 1; i < colors.length; i++) {
                    colors[i] = colors[0];
                }
            }

            printColors.reset(colors);
            this.trigger('configurationChanged');
            this.trigger("priceChanged");
        },

        hasDefaultColors: function () {
            return this.$hasDefaultColors;
        },

        getPrintColorsAsRGB: function () {
            var ret = [];

            if(this.$.design.$.colors.size() === this.$.printColors.size()){
                // go in the direction of the layers of the design
                for (var i = 0; i < this.$.design.$.colors.$items.length; i++) {
                    var designColor = this.$.design.$.colors.$items[i];
                    var printColor = this.$.printColors.$items[i];
                    ret[designColor.$.layer] = printColor.color().toRGB().toHexString();
                }
            }

            return ret;
        },

        setColor: function (layerIndex, color) {
            var printType = this.$.printType;

            if (!(color instanceof PrintTypeColor)) {
                color = printType.getClosestPrintColor(color);
            }

            if (!printType.containsPrintTypeColor(color)) {
                throw new Error("Color not contained in print type");
            }

            var printColors = this.$.printColors.$items;

            if (printColors[layerIndex] === color) {
                return;
            }

            printColors.splice(layerIndex, 1, color);

            if (printType.$.id === PrintType.Mapping.SpecialFlex) {
                // convert all other layers to the new color
                for (var i = 0; i < printColors.length; i++) {
                    if (i !== layerIndex) {
                        printColors[i] = printColors[layerIndex];
                    }
                }
            }

            this.$hasDefaultColors = _.isEqual(printColors, this.$defaultPrintColors);

            this.$.printColors.reset(printColors);

            this.trigger('configurationChanged');
            this.trigger("priceChanged");
        },

        size: function () {
            if (this.$.design && this.$.design.$.size && this.$.printType && this.$.printType.$.dpi) {
                var dpi = this.$.printType.$.dpi;
                if (!this.$sizeCache[dpi]) {
                    this.$sizeCache[dpi] = UnitUtil.convertSizeToMm(this.$.design.$.size, dpi);
                }

                return this.$sizeCache[dpi];
            }

            return Size.empty;
        }.onChange("_dpi", "design"),

        // TODO: add onchange for design.restriction.allowScale
        isScalable: function () {
            return this.get("printType.isScalable()") && this.get("design.restrictions.allowScale");
        }.onChange("printType"),

        _validatePrintTypeSize: function (printType, width, height, scale) {
            this.callBase();

            if (!printType || !scale) {
                return;
            }

            this._setError("minBounds", !printType.isShrinkable() && Math.min(Math.abs(scale.x), Math.abs(scale.y)) * 100 < (this.get("design.restrictions.minimumScale")));

        },

        price: function () {

            var usedPrintColors = [],
                price = this.callBase();

            this.$.printColors.each(function (printColor) {
                if (_.indexOf(usedPrintColors, printColor) === -1) {
                    usedPrintColors.push(printColor);
                }
            });

            for (var i = 0; i < usedPrintColors.length; i++) {
                price.add((usedPrintColors[i]).get("price"));
            }

            price.add(this.get('_designCommission'));

            return price;

        }.on("priceChanged").onChange("_designCommission", "_printTypePrice"),

        getPossiblePrintTypes: function (appearance) {
            var ret = [],
                printArea = this.$.printArea,
                design = this.$.design;

            if (printArea && appearance && design) {
                ret = ProductUtil.getPossiblePrintTypesForDesignOnPrintArea(design, printArea, appearance.$.id);
            }

            return ret;
        }.onChange("printArea", "design"),

        compose: function () {
            var ret = this.callBase();

            var transform = [],
                scale = this.$.scale,
                rotation = this.$.rotation,

                width = this.width(),
                height = this.height();

            if (rotation) {
                transform.push("rotate(" + rotation + "," + Math.round(width / 2, 3) + "," + Math.round(height / 2, 3) + ")");
            }

            if (scale && (scale.x < 0 || scale.y < 0)) {
                transform.push("scale(" + (scale.x < 0 ? -1 : 1) + "," + (scale.y < 0 ? -1 : 1) + ")");
            }

            var designId = this.$.design.$.wtfMbsId;
            ret.content = {
                unit: "mm",
                dpi: "25.4",
                svg: {
                    image: {
                        transform: transform.join(" "),
                        width: Math.round(width, 3),
                        height: Math.round(height, 3),
                        designId: designId
                    }
                }
            };

            delete ret.design;

            var printColorIds = [],
                printColorRGBs = [];

            this.$.printColors.each(function (printColor) {
                printColorIds.push(printColor.$.id);
                printColorRGBs.push(printColor.color().toString())
            });

            if (this.$.printType.isPrintColorColorSpace()) {
                ret.content.svg.image.printColorIds = printColorIds.join(" ");
            } else {
                ret.content.svg.image.printColorRGBs = printColorRGBs.join(" ");
            }

            ret.restrictions = {
                changeable: true
            };

            return ret;
        },
        parse: function (data) {
            data = this.callBase();

            data.designs = undefined;

            if(data.printArea){
                // remove printArea from payload since it is the wrong one
                // it will be set within the initSchema methods
                this.$$.printArea = data.printArea;
                data.printArea = null;
            }

            if (data.content) {
                this.$$.svg = data.content.svg;
            }

            return data;
        },

        init: function(callback) {

            var self = this,
                $$ = self.$$,
                svg = $$.svg,
                printType = this.$.printType,
                printArea,
                design;
            if(svg){
                design = this.$context.$contextModel.$context.createEntity(Design, svg.image.designId);
            } else {
                design = this.$.design;
            }

            flow()
                .par(function(cb){
                    design.fetch(null, cb);
                }, function(cb) {
                    printType.fetch(null, cb);
                })
                .seq(function() {
                    if($$.printArea){
                        printArea = self.$context.$contextModel.$.productType.getPrintAreaById($$.printArea.$.id)
                    } else {
                        printArea = self.$.printArea;
                    }
                })
                .seq(function () {
                    self.set({
                        design: design,
                        printArea: printArea
                    })
                })
                .seq(function() {
                    var printType = self.$.printType;

                    // set print colors
                    var printColors = [],
                        defaultPrintColors = [],
                        designColors = design.$.colors,
                        values;

                    if (svg) {

                        var key,
                            method;

                        if (svg.image.hasOwnProperty("printColorIds")) {
                            key = "printColorIds";
                            method = "getPrintColorById";
                        } else {
                            key = "printColorRGBs";
                            method = "getClosestPrintColor";
                        }

                        values = svg.image[key].split(" ");
                        for (var i = 0; i < values.length; i++) {
                            printColors.push(printType[method](values[i]));
                        }
                    } else if (designColors) {
                            designColors.each(function (designColor) {
                                var closestPrintColor = printType.getClosestPrintColor(designColor.$["default"]);
                                printColors.push(closestPrintColor);
                                defaultPrintColors.push(closestPrintColor);
                            });

                            self.$hasDefaultColors = true;
                            self.$defaultPrintColors = defaultPrintColors;

                        }

                    self.$.printColors.reset(printColors);
                })
                .seq(function() {
                    var match,
                        type,
                        values,
                        ret = {
                            scale: {
                                x: svg.image.width / design.$.size.$.width,
                                y: svg.image.height / design.$.size.$.height
                            }
                        };

                    var regExp = /^(\w+)\(([^(]+)\)/ig;
                    while (match = regExp.exec(svg.image.transform)) {
                        type = match[1];
                        values = match[2].split(",");
                        if (type === "rotate") {
                            ret.rotation = parseFloat(values.shift());
                        } else if (type === "scale") {
                            // only flipping
                            var scale = values;
                            ret.scale.x *= scale[0] < 0 ? -1 : 1;
                            ret.scale.x *= scale[1] < 0 ? -1 : 1;
                        }
                    }

                    self.set(ret);

                })
                .exec(callback)

        }
    });
});<commit_msg>fixed initialization of DesignConfiguration<commit_after>define(['sprd/entity/Configuration', 'sprd/entity/Size', 'sprd/util/UnitUtil', 'sprd/model/Design', "sprd/entity/PrintTypeColor", "underscore", "sprd/model/PrintType", "sprd/util/ProductUtil", "js/core/List", "flow"], function (Configuration, Size, UnitUtil, Design, PrintTypeColor, _, PrintType, ProductUtil, List, flow) {

    var undefined;

    return Configuration.inherit('sprd.model.DesignConfiguration', {

        schema: {
            type: String,
            content: Object,
            design: Design,
            restrictions: Object
        },

        defaults: {
            type: 'design',
            _dpi: "{printType.dpi}",

            design: null,

            _designCommission: "{design.price}"
        },

        ctor: function () {
            this.$sizeCache = {};
            this.$$ = {};
            this.callBase();
        },

        _commitPrintType: function (printType) {
            if (!this.$entityInitialized) {
                return;
            }
            // print type changed -> convert colors

            if (!printType || !printType.get('restrictions.colorSpace')) {
                return;
            }

            var colors = [],
                printColors = this.$.printColors;

            printColors.each(function (printColor) {
                colors.push(printType.getClosestPrintColor(printColor.color()));
            });

            if (printType.$.id === PrintType.Mapping.SpecialFlex) {
                // convert all colors to the first one
                for (var i = 1; i < colors.length; i++) {
                    colors[i] = colors[0];
                }
            }

            printColors.reset(colors);
            this.trigger('configurationChanged');
            this.trigger("priceChanged");
        },

        hasDefaultColors: function () {
            return this.$hasDefaultColors;
        },

        getPrintColorsAsRGB: function () {
            var ret = [];

            if (this.$.design.$.colors.size() === this.$.printColors.size()) {
                // go in the direction of the layers of the design
                for (var i = 0; i < this.$.design.$.colors.$items.length; i++) {
                    var designColor = this.$.design.$.colors.$items[i];
                    var printColor = this.$.printColors.$items[i];
                    ret[designColor.$.layer] = printColor.color().toRGB().toHexString();
                }
            }

            return ret;
        },

        setColor: function (layerIndex, color) {
            var printType = this.$.printType;

            if (!(color instanceof PrintTypeColor)) {
                color = printType.getClosestPrintColor(color);
            }

            if (!printType.containsPrintTypeColor(color)) {
                throw new Error("Color not contained in print type");
            }

            var printColors = this.$.printColors.$items;

            if (printColors[layerIndex] === color) {
                return;
            }

            printColors.splice(layerIndex, 1, color);

            if (printType.$.id === PrintType.Mapping.SpecialFlex) {
                // convert all other layers to the new color
                for (var i = 0; i < printColors.length; i++) {
                    if (i !== layerIndex) {
                        printColors[i] = printColors[layerIndex];
                    }
                }
            }

            this.$hasDefaultColors = _.isEqual(printColors, this.$defaultPrintColors);

            this.$.printColors.reset(printColors);

            this.trigger('configurationChanged');
            this.trigger("priceChanged");
        },

        size: function () {
            if (this.$.design && this.$.design.$.size && this.$.printType && this.$.printType.$.dpi) {
                var dpi = this.$.printType.$.dpi;
                if (!this.$sizeCache[dpi]) {
                    this.$sizeCache[dpi] = UnitUtil.convertSizeToMm(this.$.design.$.size, dpi);
                }

                return this.$sizeCache[dpi];
            }

            return Size.empty;
        }.onChange("_dpi", "design"),

        // TODO: add onchange for design.restriction.allowScale
        isScalable: function () {
            return this.get("printType.isScalable()") && this.get("design.restrictions.allowScale");
        }.onChange("printType"),

        _validatePrintTypeSize: function (printType, width, height, scale) {
            this.callBase();

            if (!printType || !scale) {
                return;
            }

            this._setError("minBounds", !printType.isShrinkable() && Math.min(Math.abs(scale.x), Math.abs(scale.y)) * 100 < (this.get("design.restrictions.minimumScale")));

        },

        price: function () {

            var usedPrintColors = [],
                price = this.callBase();

            this.$.printColors.each(function (printColor) {
                if (_.indexOf(usedPrintColors, printColor) === -1) {
                    usedPrintColors.push(printColor);
                }
            });

            for (var i = 0; i < usedPrintColors.length; i++) {
                price.add((usedPrintColors[i]).get("price"));
            }

            price.add(this.get('_designCommission'));

            return price;

        }.on("priceChanged").onChange("_designCommission", "_printTypePrice"),

        getPossiblePrintTypes: function (appearance) {
            var ret = [],
                printArea = this.$.printArea,
                design = this.$.design;

            if (printArea && appearance && design) {
                ret = ProductUtil.getPossiblePrintTypesForDesignOnPrintArea(design, printArea, appearance.$.id);
            }

            return ret;
        }.onChange("printArea", "design"),

        compose: function () {
            var ret = this.callBase();

            var transform = [],
                scale = this.$.scale,
                rotation = this.$.rotation,

                width = this.width(),
                height = this.height();

            if (rotation) {
                transform.push("rotate(" + rotation + "," + Math.round(width / 2, 3) + "," + Math.round(height / 2, 3) + ")");
            }

            if (scale && (scale.x < 0 || scale.y < 0)) {
                transform.push("scale(" + (scale.x < 0 ? -1 : 1) + "," + (scale.y < 0 ? -1 : 1) + ")");
            }

            var designId = this.$.design.$.wtfMbsId;
            ret.content = {
                unit: "mm",
                dpi: "25.4",
                svg: {
                    image: {
                        transform: transform.join(" "),
                        width: Math.round(width, 3),
                        height: Math.round(height, 3),
                        designId: designId
                    }
                }
            };

            delete ret.design;

            var printColorIds = [],
                printColorRGBs = [];

            this.$.printColors.each(function (printColor) {
                printColorIds.push(printColor.$.id);
                printColorRGBs.push(printColor.color().toString())
            });

            if (this.$.printType.isPrintColorColorSpace()) {
                ret.content.svg.image.printColorIds = printColorIds.join(" ");
            } else {
                ret.content.svg.image.printColorRGBs = printColorRGBs.join(" ");
            }

            ret.restrictions = {
                changeable: true
            };

            return ret;
        },
        parse: function (data) {
            data = this.callBase();

            data.designs = undefined;

            if (data.printArea) {
                // remove printArea from payload since it is the wrong one
                // it will be set within the initSchema methods
                this.$$.printArea = data.printArea;
                data.printArea = null;
            }

            if (data.content) {
                this.$$.svg = data.content.svg;
            }

            return data;
        },

        init: function (callback) {

            var self = this,
                $$ = self.$$,
                svg = $$.svg,
                printType = this.$.printType,
                printArea,
                design;

            if (svg) {
                design = this.$context.$contextModel.$context.createEntity(Design, svg.image.designId);
            } else {
                design = this.$.design;
            }

            flow()
                .par(function (cb) {
                    design.fetch(null, cb);
                }, function (cb) {
                    printType.fetch(null, cb);
                })
                .seq(function () {
                    if ($$.printArea) {
                        printArea = self.$context.$contextModel.$.productType.getPrintAreaById($$.printArea.$.id)
                    } else {
                        printArea = self.$.printArea;
                    }
                })
                .seq(function () {
                    self.set({
                        design: design,
                        printArea: printArea
                    })
                })
                .seq(function () {
                    var printType = self.$.printType;

                    // set print colors
                    var printColors = [],
                        defaultPrintColors = [],
                        designColors = design.$.colors,
                        values;

                    if (svg) {

                        var key,
                            method;

                        if (svg.image.hasOwnProperty("printColorIds")) {
                            key = "printColorIds";
                            method = "getPrintColorById";
                        } else {
                            key = "printColorRGBs";
                            method = "getClosestPrintColor";
                        }

                        values = svg.image[key].split(" ");
                        for (var i = 0; i < values.length; i++) {
                            printColors.push(printType[method](values[i]));
                        }
                    } else if (designColors) {
                        designColors.each(function (designColor) {
                            var closestPrintColor = printType.getClosestPrintColor(designColor.$["default"]);
                            printColors.push(closestPrintColor);
                            defaultPrintColors.push(closestPrintColor);
                        });

                        self.$hasDefaultColors = true;
                        self.$defaultPrintColors = defaultPrintColors;

                    }

                    self.$.printColors.reset(printColors);
                })
                .seq(function () {

                    if (svg) {
                        var match,
                            type,
                            values,
                            ret = {
                                scale: {
                                    x: svg.image.width / design.$.size.$.width,
                                    y: svg.image.height / design.$.size.$.height
                                }
                            };

                        var regExp = /^(\w+)\(([^(]+)\)/ig;
                        while (match = regExp.exec(svg.image.transform)) {
                            type = match[1];
                            values = match[2].split(",");
                            if (type === "rotate") {
                                ret.rotation = parseFloat(values.shift());
                            } else if (type === "scale") {
                                // only flipping
                                var scale = values;
                                ret.scale.x *= scale[0] < 0 ? -1 : 1;
                                ret.scale.x *= scale[1] < 0 ? -1 : 1;
                            }
                        }

                        self.set(ret);
                    }
                })
                .exec(callback)

        }
    });
});<|endoftext|>


<commit_before>// See https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
const ImportSortGroups = [
  // Side effect imports.
  // eslint-disable-next-line no-useless-escape
  [`^\u0000`],
  // Glimmer & Ember Dependencies
  [`^(@ember/|@glimmer|ember$)`],
  // Packages.
  // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
  // But not our packages or packages starting with ember-
  // eslint-disable-next-line no-useless-escape
  [`^(?!@ember\-data)(?!ember-)(@?\\w)`],
  // Packages starting with ember-
  // eslint-disable-next-line no-useless-escape
  [`^ember\-`],
  // Our Packages.
  // Things that start with @ember-data
  // eslint-disable-next-line no-useless-escape
  [`^@ember\-data`],
  // Absolute imports and other imports such as Vue-style `@/foo`.
  // Anything that does not start with a dot.
  ['^[^.]'],
  // Relative imports.
  // Anything that starts with a dot.
  // eslint-disable-next-line no-useless-escape
  [`^\.`],
];

module.exports = {
  parser: 'babel-eslint',
  root: true,
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'module',
  },
  plugins: ['prettier', 'qunit', 'mocha', 'simple-import-sort', 'import'],
  extends: ['eslint:recommended', 'prettier'],
  rules: {
    'no-restricted-globals': ['error', { name: 'Promise', message: 'Global Promise does not work in IE11' }],
    'mocha/no-exclusive-tests': 'error',
    'prettier/prettier': 'error',
    'no-unused-vars': ['error', { args: 'none' }],
    'no-cond-assign': ['error', 'except-parens'],
    eqeqeq: 'error',
    'no-eval': 'error',
    'new-cap': ['error', { capIsNew: false }],
    'no-caller': 'error',
    'no-eq-null': 'error',
    'no-console': 'error', // no longer recommended in eslint v6, this restores it
    'simple-import-sort/sort': ['error', { groups: ImportSortGroups }],
    'sort-imports': 'off',
    'import/order': 'off',
    'import/first': 'error',
    'import/newline-after-import': 'error',
    // this rule doesn't work properly with --fix
    // https://github.com/benmosher/eslint-plugin-import/issues/1504
    'import/no-duplicates': 'warn',

    // Too many false positives
    // See https://github.com/eslint/eslint/issues/11899 and similar
    'require-atomic-updates': 'off',
  },
  globals: {
    heimdall: true,
    Map: false,
    WeakMap: true,
    Set: true,
    Promise: false,
  },
  env: {
    browser: true,
    node: false,
  },
  overrides: [
    // TypeScript files
    {
      files: ['**/*.ts'],
      parser: '@typescript-eslint/parser',
      parserOptions: {
        sourceType: 'module',
      },
      plugins: ['@typescript-eslint', 'ember-data', 'simple-import-sort', 'import'],
      extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended'],
      rules: {
        '@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
        'no-unused-vars': 'off',
        'require-atomic-updates': 'off',
        'ember-data/prefer-type-only-import': 'error',
        'simple-import-sort/sort': ['error', { groups: ImportSortGroups }],
        'sort-imports': 'off',
        'import/order': 'off',
        'import/first': 'error',
        'import/newline-after-import': 'error',
        // this rule doesn't work properly with --fix
        // https://github.com/benmosher/eslint-plugin-import/issues/1504
        'import/no-duplicates': 'warn',
      },
    },

    // node files
    {
      files: [
        '.mocharc.js',
        '.eslintrc.js',
        '.prettierrc.js',
        'bin/**',
        'packages/private-build-infra/src/**/*.js',
        'packages/unpublished-test-infra/src/**/*.js',
        'packages/unpublished-eslint-rules/src/**/*.js',
        'packages/*/.ember-cli.js',
        'packages/*/.eslintrc.js',
        'packages/*/.template-lintrc.js',
        'packages/*/ember-cli-build.js',
        'packages/*/index.js',
        'packages/*/testem.js',
        'packages/*/blueprints/*/index.js',
        'packages/*/config/**/*.js',
        'packages/*/tests/dummy/config/**/*.js',
        'packages/*/node-tests/**/*.js',
      ],
      excludedFiles: [
        'packages/*/addon/**',
        'packages/*/addon-test-support/**',
        'packages/*/app/**',
        'packages/*/tests/dummy/app/**',
      ],
      parserOptions: {
        sourceType: 'script',
        ecmaVersion: 2015,
      },
      env: {
        browser: false,
        node: true,
        es6: true,
      },
      plugins: ['node', 'import'],
      extends: 'plugin:node/recommended',
      rules: {
        'simple-import-sort/sort': 'off',
        'no-restricted-globals': 'off',
        'import/first': 'error',
        'import/newline-after-import': 'error',
        'import/no-duplicates': 'error',
        'import/order': ['error', { 'newlines-between': 'always' }],
      },
    },

    // node tests
    {
      files: ['packages/*/node-tests/**', 'packages/unpublished-test-infra/src/node-test-helpers/**/*'],
      env: {
        mocha: true,
      },
      rules: {
        'no-restricted-globals': 'off',
      },
    },

    // docs
    {
      files: ['packages/-ember-data/node-tests/docs/*.js'],
      env: {
        qunit: true,
        es6: false,
      },
      rules: {
        'no-restricted-globals': 'off',
      },
    },

    // bin files
    {
      files: ['bin/**'],
      // eslint-disable-next-line node/no-unpublished-require
      rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
        'no-console': 'off',
        'no-process-exit': 'off',
        'node/no-unpublished-require': 'off',
        'node/no-unsupported-features/node-builtins': 'off',
      }),
    },
  ],
};
<commit_msg>Enabled eslint-plugin-qunit (#6895)<commit_after>// See https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
const ImportSortGroups = [
  // Side effect imports.
  // eslint-disable-next-line no-useless-escape
  [`^\u0000`],
  // Glimmer & Ember Dependencies
  [`^(@ember/|@glimmer|ember$)`],
  // Packages.
  // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
  // But not our packages or packages starting with ember-
  // eslint-disable-next-line no-useless-escape
  [`^(?!@ember\-data)(?!ember-)(@?\\w)`],
  // Packages starting with ember-
  // eslint-disable-next-line no-useless-escape
  [`^ember\-`],
  // Our Packages.
  // Things that start with @ember-data
  // eslint-disable-next-line no-useless-escape
  [`^@ember\-data`],
  // Absolute imports and other imports such as Vue-style `@/foo`.
  // Anything that does not start with a dot.
  ['^[^.]'],
  // Relative imports.
  // Anything that starts with a dot.
  // eslint-disable-next-line no-useless-escape
  [`^\.`],
];

module.exports = {
  parser: 'babel-eslint',
  root: true,
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'module',
  },
  plugins: ['prettier', 'qunit', 'mocha', 'simple-import-sort', 'import'],
  extends: ['eslint:recommended', 'prettier', 'plugin:qunit/recommended'],
  rules: {
    'no-restricted-globals': ['error', { name: 'Promise', message: 'Global Promise does not work in IE11' }],
    'mocha/no-exclusive-tests': 'error',
    'prettier/prettier': 'error',
    'no-unused-vars': ['error', { args: 'none' }],
    'no-cond-assign': ['error', 'except-parens'],
    eqeqeq: 'error',
    'no-eval': 'error',
    'new-cap': ['error', { capIsNew: false }],
    'no-caller': 'error',
    'no-eq-null': 'error',
    'no-console': 'error', // no longer recommended in eslint v6, this restores it
    'simple-import-sort/sort': ['error', { groups: ImportSortGroups }],
    'sort-imports': 'off',
    'import/order': 'off',
    'import/first': 'error',
    'import/newline-after-import': 'error',
    // this rule doesn't work properly with --fix
    // https://github.com/benmosher/eslint-plugin-import/issues/1504
    'import/no-duplicates': 'warn',

    // Too many false positives
    // See https://github.com/eslint/eslint/issues/11899 and similar
    'require-atomic-updates': 'off',

    // eslint-plugin-qunit
    'qunit/assert-args': 'off',
    'qunit/literal-compare-order': 'off',
    'qunit/no-identical-names': 'off',
    'qunit/no-ok-equality': 'off',
    'qunit/require-expect': 'off',
    'qunit/resolve-async': 'off',
  },
  globals: {
    heimdall: true,
    Map: false,
    WeakMap: true,
    Set: true,
    Promise: false,
  },
  env: {
    browser: true,
    node: false,
  },
  overrides: [
    // TypeScript files
    {
      files: ['**/*.ts'],
      parser: '@typescript-eslint/parser',
      parserOptions: {
        sourceType: 'module',
      },
      plugins: ['@typescript-eslint', 'ember-data', 'simple-import-sort', 'import'],
      extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended'],
      rules: {
        '@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
        'no-unused-vars': 'off',
        'require-atomic-updates': 'off',
        'ember-data/prefer-type-only-import': 'error',
        'simple-import-sort/sort': ['error', { groups: ImportSortGroups }],
        'sort-imports': 'off',
        'import/order': 'off',
        'import/first': 'error',
        'import/newline-after-import': 'error',
        // this rule doesn't work properly with --fix
        // https://github.com/benmosher/eslint-plugin-import/issues/1504
        'import/no-duplicates': 'warn',
      },
    },

    // node files
    {
      files: [
        '.mocharc.js',
        '.eslintrc.js',
        '.prettierrc.js',
        'bin/**',
        'packages/private-build-infra/src/**/*.js',
        'packages/unpublished-test-infra/src/**/*.js',
        'packages/unpublished-eslint-rules/src/**/*.js',
        'packages/*/.ember-cli.js',
        'packages/*/.eslintrc.js',
        'packages/*/.template-lintrc.js',
        'packages/*/ember-cli-build.js',
        'packages/*/index.js',
        'packages/*/testem.js',
        'packages/*/blueprints/*/index.js',
        'packages/*/config/**/*.js',
        'packages/*/tests/dummy/config/**/*.js',
        'packages/*/node-tests/**/*.js',
      ],
      excludedFiles: [
        'packages/*/addon/**',
        'packages/*/addon-test-support/**',
        'packages/*/app/**',
        'packages/*/tests/dummy/app/**',
      ],
      parserOptions: {
        sourceType: 'script',
        ecmaVersion: 2015,
      },
      env: {
        browser: false,
        node: true,
        es6: true,
      },
      plugins: ['node', 'import'],
      extends: 'plugin:node/recommended',
      rules: {
        'simple-import-sort/sort': 'off',
        'no-restricted-globals': 'off',
        'import/first': 'error',
        'import/newline-after-import': 'error',
        'import/no-duplicates': 'error',
        'import/order': ['error', { 'newlines-between': 'always' }],
      },
    },

    // node tests
    {
      files: ['packages/*/node-tests/**', 'packages/unpublished-test-infra/src/node-test-helpers/**/*'],
      env: {
        mocha: true,
      },
      rules: {
        'no-restricted-globals': 'off',
      },
    },

    // docs
    {
      files: ['packages/-ember-data/node-tests/docs/*.js'],
      env: {
        qunit: true,
        es6: false,
      },
      rules: {
        'no-restricted-globals': 'off',
      },
    },

    // bin files
    {
      files: ['bin/**'],
      // eslint-disable-next-line node/no-unpublished-require
      rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
        'no-console': 'off',
        'no-process-exit': 'off',
        'node/no-unpublished-require': 'off',
        'node/no-unsupported-features/node-builtins': 'off',
      }),
    },
  ],
};
<|endoftext|>


<commit_before>module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:vue/recommended',
    'plugin:jest/recommended',
    '@nuxtjs/eslint-config-typescript',
    'prettier'
  ],
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: ['@typescript-eslint', 'vue', 'jest'],
  // add your custom rules here
  rules: {
    'no-console': [
      'error',
      {
        allow: ['warn', 'error']
      }
    ],
    'no-trailing-spaces': 'error',
    'no-empty': [
      'error',
      {
        allowEmptyCatch: true
      }
    ],
    camelcase: 'off',
    '@typescript-eslint/camelcase': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    eqeqeq: 'error',
    'prefer-template': 'error',
    // https://teppeis.hatenablog.com/entry/2019/02/typescript-eslint
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error',
    'no-use-before-define': 'off',
    '@typescript-eslint/no-use-before-define': 'error',
    'no-useless-constructor': 'off',
    '@typescript-eslint/no-useless-constructor': 'error'
  }
}
<commit_msg>Fix eslint configuration<commit_after>module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  extends: [
    '@nuxtjs/eslint-config-typescript',
    'eslint:recommended',
    'plugin:jest/recommended',
    'prettier'
  ],
  plugins: ['jest'],
  // add your custom rules here
  rules: {
    'no-console': [
      'error',
      {
        allow: ['warn', 'error']
      }
    ],
    'no-trailing-spaces': 'error',
    'no-empty': [
      'error',
      {
        allowEmptyCatch: true
      }
    ],
    camelcase: 'off',
    // '@typescript-eslint/camelcase': 'off',
    // '@typescript-eslint/explicit-function-return-type': 'off',
    eqeqeq: 'error',
    // 'prefer-template': 'error',
    // https://teppeis.hatenablog.com/entry/2019/02/typescript-eslint
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error',
    'no-use-before-define': 'off',
    '@typescript-eslint/no-use-before-define': 'error',
    'no-useless-constructor': 'off',
    '@typescript-eslint/no-useless-constructor': 'error'
  }
}
<|endoftext|>


<commit_before>/**
 * Simple HTTP requests monitor and analyzer
 */
"use strict";

const assert = require("assert"),
  debug = require("debug")("phantomas:modules:requestsMonitor");

/**
 * Given key-value set of HTTP headers returns the set with lowercased header names
 *
 * @param {object} headers
 * @returns {object}
 */
function lowerCaseHeaders(headers) {
  var res = {};

  Object.keys(headers).forEach((headerName) => {
    res[headerName.toLowerCase()] = headers[headerName];
  });

  return res;
}

// parse given URL to get protocol and domain
function parseEntryUrl(entry) {
  const parseUrl = require("url").parse;
  var parsed;

  // asset type
  entry.type = "other";

  if (entry.url.indexOf("data:") !== 0) {
    // @see http://nodejs.org/api/url.html#url_url
    parsed = parseUrl(entry.url) || {};

    entry.protocol = parsed.protocol.replace(":", "");
    entry.domain = parsed.hostname;
    entry.query = parsed.query;

    if (entry.protocol === "https") {
      entry.isSSL = true;
    }
  } else {
    // base64 encoded data
    entry.domain = false;
    entry.protocol = false;
    entry.isBase64 = true;
  }

  return entry;
}

/**
 * Detect response content type using "Content-Type header value"
 *
 * @param {string} headerValue
 * @param {object} entry
 */
function addContentType(headerValue, entry) {
  var value = headerValue.split(";").shift().toLowerCase();
  entry.contentType = value;

  switch (value) {
    case "text/html":
      entry.type = "html";
      entry.isHTML = true;
      break;

    case "text/xml":
      entry.type = "xml";
      entry.isXML = true;
      break;

    case "text/css":
      entry.type = "css";
      entry.isCSS = true;
      break;

    case "application/x-javascript":
    case "application/javascript":
    case "text/javascript":
      entry.type = "js";
      entry.isJS = true;
      break;

    case "application/json":
      entry.type = "json";
      entry.isJSON = true;
      break;

    case "image/png":
    case "image/jpeg":
    case "image/gif":
    case "image/svg+xml":
    case "image/webp":
      entry.type = "image";
      entry.isImage = true;

      if (value === "image/svg+xml") {
        entry.isSVG = true;
      }
      break;

    case "video/webm":
      entry.type = "video";
      entry.isVideo = true;
      break;

    // @see http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts
    case "application/font-wof":
    case "application/font-woff":
    case "application/font-woff2":
    case "application/vnd.ms-fontobject":
    case "application/x-font-opentype":
    case "application/x-font-truetype":
    case "application/x-font-ttf":
    case "application/x-font-woff":
    case "font/opentype":
    case "font/ttf":
    case "font/woff":
    case "font/woff2":
      entry.type = "webfont";
      entry.isWebFont = true;

      if (/ttf|truetype$/.test(value)) {
        entry.isTTF = true;
      }
      break;

    case "application/octet-stream":
      var ext = (entry.url || "").split(".").pop();

      switch (ext) {
        // @see http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts#comment-8077637
        case "otf":
          entry.type = "webfont";
          entry.isWebFont = true;
          break;
      }
      break;

    case "image/x-icon":
    case "image/vnd.microsoft.icon":
      entry.type = "favicon";
      entry.isFavicon = true;
      break;

    default:
      debug(
        "Unknown content type found: " + value + " for <" + entry.url + ">"
      );
  }

  return entry;
}

module.exports = function (phantomas) {
  // imports
  var HTTP_STATUS_CODES = require("http").STATUS_CODES;

  // register metric
  phantomas.setMetric("requests"); // @desc total number of HTTP requests made
  phantomas.setMetric("gzipRequests"); // @desc number of gzipped HTTP responses @unreliable
  phantomas.setMetric("postRequests"); // @desc number of POST requests
  phantomas.setMetric("httpsRequests"); // @desc number of HTTPS requests
  phantomas.setMetric("notFound"); // @desc number of HTTP 404 responses
  phantomas.setMetric("bodySize"); // @desc size of the uncompressed content of all responses
  phantomas.setMetric("contentLength"); // @desc size of the compressed content of all responses, i.e. what was transfered in packets
  phantomas.setMetric("httpTrafficCompleted"); // @desc time it took to receive the last byte of the last HTTP response

  var requests = {};

  phantomas.on(
    "request",
    /** @param {Request} request **/ (request) => {
      const resId = request._requestId;
      requests[resId] = request;

      // request data
      // https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#class-request
      phantomas.emit("send", request); // @desc request has been sent
    }
  );

  phantomas.on(
    "response",
    /** @param {Response} resp **/ (resp) => {
      const resId = resp._requestId,
        request = requests[resId];

      var entry = {
        id: resId,
        url: resp.url,
        method: request.method,
        headers: lowerCaseHeaders(resp.headers), // All header names are lower-case
        bodySize: resp.dataLength,
        transferedSize: resp.encodedDataLength,
      };

      // this is set to zero when requests interception is enabled
      // use Content-Length response header instead
      if (entry.transferedSize == 0) {
        entry.transferedSize = parseInt(
          entry.headers["content-length"] || "0",
          10
        );
      }

      // that's the response size as reported by Chrome's dev tools (headers + compressed body)
      // note: base64-encoded resources do not have "resp.headersText" set
      entry.responseSize = entry.transferedSize;

      phantomas.log("headers: %j", resp);

      entry = parseEntryUrl(entry);

      /**
       * Time to First Byte is the amount of time it takes for the browser
       * to receive the first byte of data from the server
       * after the browser makes the request.
       *
       * https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#timing-explanation
       * https://www.w3.org/TR/navigation-timing/#performancetiming
       * https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ResourceTiming
       *
       * "Throughout this work, time is measured in milliseconds"
       */
      if (!entry.isBase64) {
        // resp.timing is empty when handling data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D
        assert(
          typeof resp.timing !== "undefined",
          "resp.timing is empty when handling " + resp.url
        );

        // how long a given request stalled waiting for DNS, proxy, connection, SSL negotation, etc.
        entry.stalled = resp.timing.sendStart;

        // how it took to receive a first byte of the response after making a request
        entry.timeToFirstByte =
          resp.timing.receiveHeadersEnd - resp.timing.sendEnd;

        // difference between when the request was sent and when it was received
        entry.timeToLastByte = resp._timestamp - request._timestamp;
      }

      // POST requests
      if (entry.method === "POST") {
        phantomas.incrMetric("postRequests");
        phantomas.addOffender("postRequests", entry.url);
      }

      entry.headersSize = 0;

      // response content type
      // https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ResourceType
      Object.keys(entry.headers).forEach((headerName) => {
        const headerValue = entry.headers[headerName];

        entry.headersSize +=
          headerName.length +
          headerValue.length +
          2 /* ": " */ +
          2; /* line break - CR+LF */

        switch (headerName) {
          // detect content type
          case "content-type":
            entry = addContentType(headerValue, entry);
            break;

          // content compression
          // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#Directives
          case "content-encoding":
            if (headerValue === "gzip" || headerValue === "br") {
              entry.gzip = true;

              phantomas.log(
                "Response compressed with %s, %f kB -> %f kB (x%f)",
                headerValue,
                entry.bodySize / 1024,
                entry.transferedSize / 1024,
                entry.bodySize / entry.transferedSize
              );
            }

            // A format using the Brotli algorithm.
            if (headerValue === "br") {
              entry.brotli = true;
            }
            break;

          // detect cookies (issue #92)
          case "set-cookie":
            entry.hasCookies = true;
            break;
        }
      });

      // HTTP code
      entry.status = resp.status || 200; // for base64 data
      entry.statusText = HTTP_STATUS_CODES[entry.status];

      switch (entry.status) {
        case 301: // Moved Permanently
        case 302: // Found
        case 303: // See Other
          entry.isRedirect = true;
          break;

        case 404: // Not Found
          phantomas.incrMetric("notFound");
          phantomas.addOffender("notFound", entry.url);
          break;
      }

      // requests stats
      if (!entry.isBase64) {
        phantomas.incrMetric("requests");
        phantomas.addOffender("requests", {
          url: entry.url,
          type: entry.type,
          size: entry.responseSize,
        });

        phantomas.incrMetric("bodySize", entry.bodySize);
        phantomas.incrMetric("contentLength", entry.transferedSize);
      }

      if (entry.gzip) {
        phantomas.incrMetric("gzipRequests");
        phantomas.addOffender("gzipRequests", {
          url: entry.url,
          transferedSize: entry.transferedSize,
          bodySize: entry.bodySize,
        });
      }

      if (entry.isSSL) {
        phantomas.incrMetric("httpsRequests");
        phantomas.addOffender("httpsRequests", entry.url);
      }

      if (entry.isBase64) {
        phantomas.emit("base64recv", entry, resp); // @desc base64-encoded "response" has been received
      } else {
        phantomas.log(
          "recv: HTTP %d <%s> [%s]",
          entry.status,
          entry.url,
          entry.contentType
        );
        phantomas.emit("recv", entry, resp); // @desc response has been received
      }

      phantomas.log("Response metadata: %j", entry);
    }
  );

  // completion of the last HTTP request
  var loadStartedTime;
  phantomas.on("loadStarted", () => (loadStartedTime = Date.now())); // when the monitoring started?

  phantomas.on("recv", (entry) =>
    phantomas.setMetric(
      "httpTrafficCompleted",
      entry.recvEndTime - loadStartedTime
    )
  );
};
<commit_msg>requestMonitor.js: use WHATWG URL API instead of url.parse<commit_after>/**
 * Simple HTTP requests monitor and analyzer
 */
"use strict";

const assert = require("assert"),
  debug = require("debug")("phantomas:modules:requestsMonitor");

/**
 * Given key-value set of HTTP headers returns the set with lowercased header names
 *
 * @param {object} headers
 * @returns {object}
 */
function lowerCaseHeaders(headers) {
  var res = {};

  Object.keys(headers).forEach((headerName) => {
    res[headerName.toLowerCase()] = headers[headerName];
  });

  return res;
}

// parse given URL to get protocol and domain
function parseEntryUrl(entry) {
  var parsed;

  // asset type
  entry.type = "other";

  if (entry.url.indexOf("data:") !== 0) {
    // @see https://nodejs.org/api/url.html#url_class_url
    parsed = new URL(entry.url) || {};

    entry.protocol = parsed.protocol.replace(":", ""); // e.g. "http:"
    entry.domain = parsed.hostname;
    entry.query = parsed.search.substring(1)

    if (entry.protocol === "https") {
      entry.isSSL = true;
    }
  } else {
    // base64 encoded data
    entry.domain = false;
    entry.protocol = false;
    entry.isBase64 = true;
  }

  return entry;
}

/**
 * Detect response content type using "Content-Type header value"
 *
 * @param {string} headerValue
 * @param {object} entry
 */
function addContentType(headerValue, entry) {
  var value = headerValue.split(";").shift().toLowerCase();
  entry.contentType = value;

  switch (value) {
    case "text/html":
      entry.type = "html";
      entry.isHTML = true;
      break;

    case "text/xml":
      entry.type = "xml";
      entry.isXML = true;
      break;

    case "text/css":
      entry.type = "css";
      entry.isCSS = true;
      break;

    case "application/x-javascript":
    case "application/javascript":
    case "text/javascript":
      entry.type = "js";
      entry.isJS = true;
      break;

    case "application/json":
      entry.type = "json";
      entry.isJSON = true;
      break;

    case "image/png":
    case "image/jpeg":
    case "image/gif":
    case "image/svg+xml":
    case "image/webp":
      entry.type = "image";
      entry.isImage = true;

      if (value === "image/svg+xml") {
        entry.isSVG = true;
      }
      break;

    case "video/webm":
      entry.type = "video";
      entry.isVideo = true;
      break;

    // @see http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts
    case "application/font-wof":
    case "application/font-woff":
    case "application/font-woff2":
    case "application/vnd.ms-fontobject":
    case "application/x-font-opentype":
    case "application/x-font-truetype":
    case "application/x-font-ttf":
    case "application/x-font-woff":
    case "font/opentype":
    case "font/ttf":
    case "font/woff":
    case "font/woff2":
      entry.type = "webfont";
      entry.isWebFont = true;

      if (/ttf|truetype$/.test(value)) {
        entry.isTTF = true;
      }
      break;

    case "application/octet-stream":
      var ext = (entry.url || "").split(".").pop();

      switch (ext) {
        // @see http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts#comment-8077637
        case "otf":
          entry.type = "webfont";
          entry.isWebFont = true;
          break;
      }
      break;

    case "image/x-icon":
    case "image/vnd.microsoft.icon":
      entry.type = "favicon";
      entry.isFavicon = true;
      break;

    default:
      debug(
        "Unknown content type found: " + value + " for <" + entry.url + ">"
      );
  }

  return entry;
}

module.exports = function (phantomas) {
  // imports
  var HTTP_STATUS_CODES = require("http").STATUS_CODES;

  // register metric
  phantomas.setMetric("requests"); // @desc total number of HTTP requests made
  phantomas.setMetric("gzipRequests"); // @desc number of gzipped HTTP responses @unreliable
  phantomas.setMetric("postRequests"); // @desc number of POST requests
  phantomas.setMetric("httpsRequests"); // @desc number of HTTPS requests
  phantomas.setMetric("notFound"); // @desc number of HTTP 404 responses
  phantomas.setMetric("bodySize"); // @desc size of the uncompressed content of all responses
  phantomas.setMetric("contentLength"); // @desc size of the compressed content of all responses, i.e. what was transfered in packets
  phantomas.setMetric("httpTrafficCompleted"); // @desc time it took to receive the last byte of the last HTTP response

  var requests = {};

  phantomas.on(
    "request",
    /** @param {Request} request **/ (request) => {
      const resId = request._requestId;
      requests[resId] = request;

      // request data
      // https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#class-request
      phantomas.emit("send", request); // @desc request has been sent
    }
  );

  phantomas.on(
    "response",
    /** @param {Response} resp **/ (resp) => {
      const resId = resp._requestId,
        request = requests[resId];

      var entry = {
        id: resId,
        url: resp.url,
        method: request.method,
        headers: lowerCaseHeaders(resp.headers), // All header names are lower-case
        bodySize: resp.dataLength,
        transferedSize: resp.encodedDataLength,
      };

      // this is set to zero when requests interception is enabled
      // use Content-Length response header instead
      if (entry.transferedSize == 0) {
        entry.transferedSize = parseInt(
          entry.headers["content-length"] || "0",
          10
        );
      }

      // that's the response size as reported by Chrome's dev tools (headers + compressed body)
      // note: base64-encoded resources do not have "resp.headersText" set
      entry.responseSize = entry.transferedSize;

      phantomas.log("headers: %j", resp);

      entry = parseEntryUrl(entry);

      /**
       * Time to First Byte is the amount of time it takes for the browser
       * to receive the first byte of data from the server
       * after the browser makes the request.
       *
       * https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#timing-explanation
       * https://www.w3.org/TR/navigation-timing/#performancetiming
       * https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ResourceTiming
       *
       * "Throughout this work, time is measured in milliseconds"
       */
      if (!entry.isBase64) {
        // resp.timing is empty when handling data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D
        assert(
          typeof resp.timing !== "undefined",
          "resp.timing is empty when handling " + resp.url
        );

        // how long a given request stalled waiting for DNS, proxy, connection, SSL negotation, etc.
        entry.stalled = resp.timing.sendStart;

        // how it took to receive a first byte of the response after making a request
        entry.timeToFirstByte =
          resp.timing.receiveHeadersEnd - resp.timing.sendEnd;

        // difference between when the request was sent and when it was received
        entry.timeToLastByte = resp._timestamp - request._timestamp;
      }

      // POST requests
      if (entry.method === "POST") {
        phantomas.incrMetric("postRequests");
        phantomas.addOffender("postRequests", entry.url);
      }

      entry.headersSize = 0;

      // response content type
      // https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ResourceType
      Object.keys(entry.headers).forEach((headerName) => {
        const headerValue = entry.headers[headerName];

        entry.headersSize +=
          headerName.length +
          headerValue.length +
          2 /* ": " */ +
          2; /* line break - CR+LF */

        switch (headerName) {
          // detect content type
          case "content-type":
            entry = addContentType(headerValue, entry);
            break;

          // content compression
          // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#Directives
          case "content-encoding":
            if (headerValue === "gzip" || headerValue === "br") {
              entry.gzip = true;

              phantomas.log(
                "Response compressed with %s, %f kB -> %f kB (x%f)",
                headerValue,
                entry.bodySize / 1024,
                entry.transferedSize / 1024,
                entry.bodySize / entry.transferedSize
              );
            }

            // A format using the Brotli algorithm.
            if (headerValue === "br") {
              entry.brotli = true;
            }
            break;

          // detect cookies (issue #92)
          case "set-cookie":
            entry.hasCookies = true;
            break;
        }
      });

      // HTTP code
      entry.status = resp.status || 200; // for base64 data
      entry.statusText = HTTP_STATUS_CODES[entry.status];

      switch (entry.status) {
        case 301: // Moved Permanently
        case 302: // Found
        case 303: // See Other
          entry.isRedirect = true;
          break;

        case 404: // Not Found
          phantomas.incrMetric("notFound");
          phantomas.addOffender("notFound", entry.url);
          break;
      }

      // requests stats
      if (!entry.isBase64) {
        phantomas.incrMetric("requests");
        phantomas.addOffender("requests", {
          url: entry.url,
          type: entry.type,
          size: entry.responseSize,
        });

        phantomas.incrMetric("bodySize", entry.bodySize);
        phantomas.incrMetric("contentLength", entry.transferedSize);
      }

      if (entry.gzip) {
        phantomas.incrMetric("gzipRequests");
        phantomas.addOffender("gzipRequests", {
          url: entry.url,
          transferedSize: entry.transferedSize,
          bodySize: entry.bodySize,
        });
      }

      if (entry.isSSL) {
        phantomas.incrMetric("httpsRequests");
        phantomas.addOffender("httpsRequests", entry.url);
      }

      if (entry.isBase64) {
        phantomas.emit("base64recv", entry, resp); // @desc base64-encoded "response" has been received
      } else {
        phantomas.log(
          "recv: HTTP %d <%s> [%s]",
          entry.status,
          entry.url,
          entry.contentType
        );
        phantomas.emit("recv", entry, resp); // @desc response has been received
      }

      phantomas.log("Response metadata: %j", entry);
    }
  );

  // completion of the last HTTP request
  var loadStartedTime;
  phantomas.on("loadStarted", () => (loadStartedTime = Date.now())); // when the monitoring started?

  phantomas.on("recv", (entry) =>
    phantomas.setMetric(
      "httpTrafficCompleted",
      entry.recvEndTime - loadStartedTime
    )
  );
};
<|endoftext|>


<commit_before>module.exports = {
    env: {
        browser: true,
        es6: true,
        node: true,
    },
    parserOptions: {
        ecmaVersion: 8,
        sourceType: 'module',
    },
    parser: 'babel-eslint',
    plugins: [
        'react',
        'jsx-a11y',
    ],
    rules: {
        //////////////////////////////////////////
        // Starting from the top of ESLint rules//
        //////////////////////////////////////////
        'no-await-in-loop': 1,
        'no-compare-neg-zero': 2,
        'no-cond-assign': 1,
        'no-console': 1,
        'no-control-regex': 2,
        'no-debugger': 0,
        'no-dupe-args': 2,
        'no-dupe-keys': 2,
        'no-duplicate-case': 2,
        'no-empty': [1, { allowEmptyCatch: true }],
        'no-empty-character-class': 1,
        'no-ex-assign': 1,
        'no-extra-boolean-cast': 2,
        'no-invalid-regexp': 2,
        'no-irregular-whitespace': [2, {
            skipStrings: true,
            skipComments: true,
            // skipRegExps: true,
            skipTemplates: true,
        }],
        'no-obj-calls': 2,
        'no-prototype-builtins': 0,
        'no-regex-spaces': 1,
        'no-sparse-arrays': 1,
        'no-template-curly-in-string': 1,
        'no-unexpected-multiline': 1,
        'no-unreachable': 1,
        'no-unsafe-finally': 1,
        'no-unsafe-negation': 1,
        'use-isnan': 2,
        'valid-jsdoc': 1,
        'valid-typeof': 2,

        'accessor-pairs': 1,
        'array-callback-return': 2,
        'block-scoped-var': 1,
        'class-methods-use-this': 1,
        complexity: 0,
        'consistent-return': 0,
        curly: 1,
        'default-case': 0,
        'dot-location': 0,
        'dot-notation': 1,
        'eqeqeq': 1,
        'guard-for-in': 1,
        'no-alert': 1,
        'no-caller': 1,
        'no-case-declarations': 1,
        'no-div-regex': 0,
        'no-else-return': 1,
        'no-empty-function': [1, { allow: ['arrowFunctions', ] }],
        'no-empty-pattern': 2,
        'no-eq-null': 0, // eqeqeq takes care of this
        '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': 0,
        'no-implicit-globals': 1,
        'no-implied-eval': 2,
        'no-invalid-this': 1,
        'no-iterator': 1,
        'no-labels': 1,
        'no-lone-blocks': 1,
        'no-loop-func': 0,
        'no-magic-numbers': 0,
        'no-multi-spaces': [1, {
            // ignoreEOLComments: true,
        }],
        'no-multi-str': 1,
        'no-new': 1,
        'no-new-func': 1,
        'no-new-wrappers': 1,
        'no-octal': 1,
        'no-param-reassign': 0,
        'no-proto': 1,
        'no-redeclare': 1,
        // 'no-restricted-properties': don't need,
        'no-return-assign': 0,
        'no-return-await': 1,
        'no-script-url': 1,
        'no-self-assign': 2,
        'no-self-compare': 2,
        'no-sequences': 1,
        'no-throw-literal': 1,
        'no-unmodified-loop-condition': 1,
        'no-unused-labels': 1,
        'no-unused-expressions': [1, {
            allowTernary: true,
            allowShortCircuit: true,
        }],
        'no-useless-call': 1,
        'no-useless-concat': 1,
        'no-useless-escape': 1,
        'no-useless-return': 1,
        'no-void': 1,
        'no-warning-comments': 0,
        'no-with': 1,
        'prefer-promise-reject-errors': 1,
        radix: 0,
        'require-await': 1,
        'vars-on-top': 0,
        'wrap-iife': [1, 'inside'],
        yoda: 1,
        strict: 0,
        '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': 2,
        'no-undef': 1,
        'no-undef-init': 1,
        'no-undefined': 0,
        'no-unused-vars': 1,
        'no-use-before-define': 2,

        //////////
        // Node //
        //////////
        '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-sync': 1,

        ////////////
        // Styling//
        ////////////
        'array-bracket-newline': 0,
        'array-bracket-spacing': 0,
        'array-element-newline': 0,
        'block-spacing': 1,
        'brace-style': 1,
        'camelcase': 0,
        'capitalized-comments': 0,
        'comma-dangle': 0,
        'comma-spacing': 1,
        'comma-style': 1,
        'consistent-this': 0,
        'eol-last': 1,
        'func-call-spacing': 1,
        'func-name-matching': 1,
        'func-names': 0,
        'func-style': [1, 'declaration'],
        'id-blacklist': 0,
        'id-length': 0,
        'id-match': 0,
        'indent': [1, 4],
        'jsx-quotes': [1, 'prefer-double'],
        'key-spacing': 1,
        'keyword-spacing': 1,
        'line-comment-positon': 0,
        'linebreak-style': 0,
        'lines-around-comment': 0,
        'max-depth': 0,
        'max-len': 0,
        'max-lines': 0,
        'max-nested-callbacks': 0,
        'max-params': [1, 2],
        'max-statements': 0,
        'max-statements-per-line': 0,
        'multiline-ternary': 0,
        'new-cap': 1,
        'new-parens': 1,
        'newline-per-chained-call': 0,
        'no-array-constructor': 1,
        'no-bitwise': 0,
        'no-continue': 0,
        'no-inline-comments': 0,
        'no-lonely-if': 1,
        'no-mixed-operators': 0,
        'no-mixed-spaces-and-tabs': 0, //other rules take care of this
        'no-multi-assign': 1,
        'no-multiple-empty-lines': 0,
        'no-nested-ternary': 0,
        'no-new-object': 1,
        'no-plusplus': 0,
        'no-restricted-syntax': 0,
        'no-tabs': 0, // other rules take care of this
        'no-ternary': 0,
        'no-trailing-spaces': 1,
        'no-underscore-dangle': 0,
        'no-unneeded-ternary': 1,
        'no-whitespace-before-property': 1,
        'nonblock-statement-body-position': 0, // other rules take care of this
        'object-curly-newline': 0,
        'object-curly-spacing': [1, 'always'],
        'object-property-newline': 0,
        'one-var': 1,
        'one-var-declaration-per-line': 1,
        'operator-assignment': 1,
        'operator-linebreak': 0,
        'padded-blocks': 0,
        'padding-line-between-statements': 0,
        'quote-props': 0,
        quotes: [1, 'single'],
        'require-jsdoc': 0,
        semi: 1,
        'semi-spacing': 1,
        'sort-keys': 0,
        'sort-vars': 0,
        'space-before-blocks': 1,
        'space-before-function-paren': [1, 'never'],
        'space-in-parens': 0,
        'space-infix-ops': 1,
        'space-unary-ops': 1,
        'spaced-comment': 0,
        'template-tag-spacing': 1,
        'unicode-bom': 0,
        'wrap-regex': 0,

        ////////
        // ES6//
        ////////
        'arrow-body-style': [1, 'as-needed'],
        'arrow-parens': [1, 'as-needed'],
        'arrow-spacing': 1,
        'constructor-super': 2,
        'generator-star-spacing': [1, { 'before': false, 'after': true }],
        'no-class-assign': 2,
        'no-confusing-arrow': 0,
        'no-const-assign': 2,
        'no-dupe-class-members': 2,
        'no-duplicate-imports': 1,
        'no-new-symbol': 2,
        'no-restricted-imports': 0,
        'no-this-before-super': 2,
        'no-useless-computed-key': 1,
        'no-useless-constructor': 1,
        'no-useless-rename': 1,
        'no-var': 1,
        'prefer-arrow-callback': 0,
        'prefer-const': 1,
        'prefer-destructuring': 0,
        'prefer-numeric-literals': 1,
        'prefer-rest-params': 1,
        'prefer-spread': 1,
        'prefer-template': 0,
        'require-yield': 1,
        'rest-spread-spacing': 1,
        'sort-imports': 0,
        'symbol-description': 1,
        'template-curly-spacing': 1,
        'yield-star-spacing': 1,

        //////////////////////////////
        // Rules changed in process //
        //////////////////////////////
        'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx'] }],
        'react/no-unescaped-entities': [0],
        'react/no-array-index-key': [0],
        'react/prop-types': [0],
        'import/newline-after-import': [0],
        'react/jsx-indent': [2, 4],
        'react/jsx-sort-props': 0,
        'react/jsx-max-props-per-line': 0,
        'react/jsx-no-literals': 0,
        'react/require-optimization': 0,
        'react/jsx-handler-names': 0,
        'react/jsx-no-bind': 1,
        'react/forbid-component-props': 0,
    },
    // Applied in everse order - react/all will override eslint:all
    extends: [
        'plugin:react/all',
        'eslint:all',
        'plugin:jsx-a11y/recommended',
    ],
};
<commit_msg>Add all react rules<commit_after>module.exports = {
    env: {
        browser: true,
        es6: true,
        node: true,
    },
    parserOptions: {
        ecmaVersion: 8,
        sourceType: 'module',
    },
    parser: 'babel-eslint',
    plugins: [
        'react',
        'jsx-a11y',
    ],
    rules: {
        //////////////////////////////////////////
        // Starting from the top of ESLint rules//
        //////////////////////////////////////////
        'no-await-in-loop': 1,
        'no-compare-neg-zero': 2,
        'no-cond-assign': 1,
        'no-console': 1,
        'no-control-regex': 2,
        'no-debugger': 0,
        'no-dupe-args': 2,
        'no-dupe-keys': 2,
        'no-duplicate-case': 2,
        'no-empty': [1, { allowEmptyCatch: true }],
        'no-empty-character-class': 1,
        'no-ex-assign': 1,
        'no-extra-boolean-cast': 2,
        'no-invalid-regexp': 2,
        'no-irregular-whitespace': [2, {
            skipStrings: true,
            skipComments: true,
            // skipRegExps: true,
            skipTemplates: true,
        }],
        'no-obj-calls': 2,
        'no-prototype-builtins': 0,
        'no-regex-spaces': 1,
        'no-sparse-arrays': 1,
        'no-template-curly-in-string': 1,
        'no-unexpected-multiline': 1,
        'no-unreachable': 1,
        'no-unsafe-finally': 1,
        'no-unsafe-negation': 1,
        'use-isnan': 2,
        'valid-jsdoc': 1,
        'valid-typeof': 2,

        'accessor-pairs': 1,
        'array-callback-return': 2,
        'block-scoped-var': 1,
        'class-methods-use-this': 1,
        complexity: 0,
        'consistent-return': 0,
        curly: 1,
        'default-case': 0,
        'dot-location': 0,
        'dot-notation': 1,
        'eqeqeq': 1,
        'guard-for-in': 1,
        'no-alert': 1,
        'no-caller': 1,
        'no-case-declarations': 1,
        'no-div-regex': 0,
        'no-else-return': 1,
        'no-empty-function': [1, { allow: ['arrowFunctions', ] }],
        'no-empty-pattern': 2,
        'no-eq-null': 0, // eqeqeq takes care of this
        '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': 0,
        'no-implicit-globals': 1,
        'no-implied-eval': 2,
        'no-invalid-this': 1,
        'no-iterator': 1,
        'no-labels': 1,
        'no-lone-blocks': 1,
        'no-loop-func': 0,
        'no-magic-numbers': 0,
        'no-multi-spaces': [1, {
            // ignoreEOLComments: true,
        }],
        'no-multi-str': 1,
        'no-new': 1,
        'no-new-func': 1,
        'no-new-wrappers': 1,
        'no-octal': 1,
        'no-param-reassign': 0,
        'no-proto': 1,
        'no-redeclare': 1,
        // 'no-restricted-properties': don't need,
        'no-return-assign': 0,
        'no-return-await': 1,
        'no-script-url': 1,
        'no-self-assign': 2,
        'no-self-compare': 2,
        'no-sequences': 1,
        'no-throw-literal': 1,
        'no-unmodified-loop-condition': 1,
        'no-unused-labels': 1,
        'no-unused-expressions': [1, {
            allowTernary: true,
            allowShortCircuit: true,
        }],
        'no-useless-call': 1,
        'no-useless-concat': 1,
        'no-useless-escape': 1,
        'no-useless-return': 1,
        'no-void': 1,
        'no-warning-comments': 0,
        'no-with': 1,
        'prefer-promise-reject-errors': 1,
        radix: 0,
        'require-await': 1,
        'vars-on-top': 0,
        'wrap-iife': [1, 'inside'],
        yoda: 1,
        strict: 0,
        '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': 2,
        'no-undef': 1,
        'no-undef-init': 1,
        'no-undefined': 0,
        'no-unused-vars': 1,
        'no-use-before-define': 2,

        //////////
        // Node //
        //////////
        '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-sync': 1,

        ////////////
        // Styling//
        ////////////
        'array-bracket-newline': 0,
        'array-bracket-spacing': 0,
        'array-element-newline': 0,
        'block-spacing': 1,
        'brace-style': 1,
        'camelcase': 0,
        'capitalized-comments': 0,
        'comma-dangle': 0,
        'comma-spacing': 1,
        'comma-style': 1,
        'consistent-this': 0,
        'eol-last': 1,
        'func-call-spacing': 1,
        'func-name-matching': 1,
        'func-names': 0,
        'func-style': [1, 'declaration'],
        'id-blacklist': 0,
        'id-length': 0,
        'id-match': 0,
        'indent': [1, 4],
        'jsx-quotes': [1, 'prefer-double'],
        'key-spacing': 1,
        'keyword-spacing': 1,
        'line-comment-positon': 0,
        'linebreak-style': 0,
        'lines-around-comment': 0,
        'max-depth': 0,
        'max-len': 0,
        'max-lines': 0,
        'max-nested-callbacks': 0,
        'max-params': [1, 2],
        'max-statements': 0,
        'max-statements-per-line': 0,
        'multiline-ternary': 0,
        'new-cap': 1,
        'new-parens': 1,
        'newline-per-chained-call': 0,
        'no-array-constructor': 1,
        'no-bitwise': 0,
        'no-continue': 0,
        'no-inline-comments': 0,
        'no-lonely-if': 1,
        'no-mixed-operators': 0,
        'no-mixed-spaces-and-tabs': 0, //other rules take care of this
        'no-multi-assign': 1,
        'no-multiple-empty-lines': 0,
        'no-nested-ternary': 0,
        'no-new-object': 1,
        'no-plusplus': 0,
        'no-restricted-syntax': 0,
        'no-tabs': 0, // other rules take care of this
        'no-ternary': 0,
        'no-trailing-spaces': 1,
        'no-underscore-dangle': 0,
        'no-unneeded-ternary': 1,
        'no-whitespace-before-property': 1,
        'nonblock-statement-body-position': 0, // other rules take care of this
        'object-curly-newline': 0,
        'object-curly-spacing': [1, 'always'],
        'object-property-newline': 0,
        'one-var': 1,
        'one-var-declaration-per-line': 1,
        'operator-assignment': 1,
        'operator-linebreak': 0,
        'padded-blocks': 0,
        'padding-line-between-statements': 0,
        'quote-props': 0,
        quotes: [1, 'single'],
        'require-jsdoc': 0,
        semi: 1,
        'semi-spacing': 1,
        'sort-keys': 0,
        'sort-vars': 0,
        'space-before-blocks': 1,
        'space-before-function-paren': [1, 'never'],
        'space-in-parens': 0,
        'space-infix-ops': 1,
        'space-unary-ops': 1,
        'spaced-comment': 0,
        'template-tag-spacing': 1,
        'unicode-bom': 0,
        'wrap-regex': 0,

        ////////
        // ES6//
        ////////
        'arrow-body-style': [1, 'as-needed'],
        'arrow-parens': [1, 'as-needed'],
        'arrow-spacing': 1,
        'constructor-super': 2,
        'generator-star-spacing': [1, { 'before': false, 'after': true }],
        'no-class-assign': 2,
        'no-confusing-arrow': 0,
        'no-const-assign': 2,
        'no-dupe-class-members': 2,
        'no-duplicate-imports': 1,
        'no-new-symbol': 2,
        'no-restricted-imports': 0,
        'no-this-before-super': 2,
        'no-useless-computed-key': 1,
        'no-useless-constructor': 1,
        'no-useless-rename': 1,
        'no-var': 1,
        'prefer-arrow-callback': 0,
        'prefer-const': 1,
        'prefer-destructuring': 0,
        'prefer-numeric-literals': 1,
        'prefer-rest-params': 1,
        'prefer-spread': 1,
        'prefer-template': 0,
        'require-yield': 1,
        'rest-spread-spacing': 1,
        'sort-imports': 0,
        'symbol-description': 1,
        'template-curly-spacing': 1,
        'yield-star-spacing': 1,

        //////////
        // React//
        //////////
        'react/display-name': 1,
        'react/forbid-component-props': 0,
        // 'react/forbid-elements': not needed,
        // 'react/forbid-prop-types': not needed,
        // 'react/forbid-foreign-prop-types': not needed,
        'react/no-array-index-key': 1,
        'react/no-children-prop': 1,
        'react/no-danger': 0,
        'react/no-danger-with-children': 1,
        'react/no-deprecated': 1,
        'react/no-did-mount-set-state': 1,
        'react/no-did-update-set-state': 1,
        'react/no-direct-mutation-state': 2,
        'react/no-find-dom-node': 1,
        'react/no-is-mounted': 1,
        'react/no-multi-comp': 0,
        'react/no-render-return-value': 1,
        'react/no-set-state': 0,
        'react/no-string-refs': 1,
        'react/no-unescaped-entities': 0,
        'react/no-unknown-property': 1,
        'react/no-unused-prop-types': 0, // don't need it
        'react/no-will-update-set-state': 2,
        'react/prefer-es6-class': 1,
        'react/prefer-stateless-function': 1,
        'react/prop-types': 0,
        'react/react-in-jsx-scope': 2,
        'react/require-default-props': 0,
        'react/require-optimization': 0,
        'react/require-render-return': 2,
        'react/self-closing-comp': 1,
        'react/sort-comp': 1,
        'react/sort-prop-types': 0,
        'react/style-prop-object': 1,
        'react/void-dom-elements-no-children': 2,

        //////////////////////////////
        // Rules changed in process //
        //////////////////////////////
        'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx'] }],
        'react/jsx-indent': [2, 4],
        'react/jsx-sort-props': 0,
        'react/jsx-max-props-per-line': 0,
        'react/jsx-no-literals': 0,
        'react/jsx-handler-names': 0,
        'react/jsx-no-bind': 1,
    },

    // Applied in reverse order - react/all will override eslint:all
    extends: [
        'plugin:react/all',
        'eslint:all',
        'plugin:jsx-a11y/recommended',
    ],
};
<|endoftext|>


<commit_before>module.exports = {
  extends: [
    'airbnb-base',
    './common.js'
  ],

  parser: 'babel-eslint',

  plugins: [
    'babel',
    'import',
  ],

  rules: {
    'func-names': 0,
    curly: ['error', 'all']
  },
};
<commit_msg>Fix import file not exists in project.<commit_after>module.exports = {
  extends: [
    'airbnb-base'
  ],

  parser: 'babel-eslint',

  plugins: [
    'babel',
    'import',
  ],

  rules: {
    'func-names': 0,
    curly: ['error', 'all']
  },
};
<|endoftext|>


<commit_before>module.exports = {
  parser: "babel-eslint",
  parserOptions: {
    ecmaFeatures: {
      modules: true,
      jsx: true
    }
  },
  plugins: [
    "react"
  ],
  extends: [
    "airbnb",
    "@octetstream"
  ],
  settings: {
    "import/resolver": {
      "babel-module": {
        cwd: __dirname,
        root: ["."],
      }
    }
  },
  rules: {
    "max-len": ["error", {
      ignoreComments: true,
      code: 80
    }],
    indent: ["error", 2, {
      SwitchCase: 1
    }],
    // TODO: Don't forget to move this rule to my personal shared config.
    "prefer-const": ["error", {
      destructuring: "all"
    }],
    "no-constant-condition": ["error", {
      checkLoops: false
    }],

    "operator-linebreak": ["error", "before"],
    "func-names": ["error", "always", {
      generators: "never"
    }],

    "react/react-in-jsx-scope": 0,
    "react/static-property-placement": ["error", "static public field"],
    "react/state-in-constructor": 0,
    "react/button-has-type": 0,
    "react/destructuring-assignment": 0,
    "react/jsx-props-no-spreading": 0,
    "react/jsx-one-expression-per-line": 0,
    "react/jsx-fragments": ["error", "element"],
    "react/prop-types": ["error", {skipUndeclared: true}],

    // ! Disable this rule because Next.js <Link> component can't deal with it
    // ! See: https://github.com/vercel/next.js/issues/5533
    "jsx-a11y/anchor-is-valid": 0
  }
}
<commit_msg>common: Remove unnecessary eslint rules<commit_after>module.exports = {
  parser: "babel-eslint",
  parserOptions: {
    ecmaFeatures: {
      modules: true,
      jsx: true
    }
  },
  plugins: [
    "react"
  ],
  extends: [
    "airbnb",
    "@octetstream"
  ],
  settings: {
    "import/resolver": {
      "babel-module": {
        cwd: __dirname,
        root: ["."],
      }
    }
  },
  rules: {
    "no-constant-condition": ["error", {
      checkLoops: false
    }],

    "func-names": ["error", "always", {
      generators: "never"
    }],

    "react/react-in-jsx-scope": 0,
    "react/static-property-placement": ["error", "static public field"],
    "react/state-in-constructor": 0,
    "react/button-has-type": 0,
    "react/destructuring-assignment": 0,
    "react/jsx-props-no-spreading": 0,
    "react/jsx-one-expression-per-line": 0,
    "react/jsx-fragments": ["error", "element"],
    "react/prop-types": ["error", {skipUndeclared: true}],

    // ! Disable this rule because Next.js <Link> component can't deal with it
    // ! See: https://github.com/vercel/next.js/issues/5533
    "jsx-a11y/anchor-is-valid": 0
  }
}
<|endoftext|>