diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..7732504 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "@aurodesignsystem/eslint-config" + ] +} diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index ff1b877..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,244 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": true - }, - "extends": ["eslint:recommended", "plugin:lit/recommended"], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parserOptions": { - "ecmaVersion": 11, - "sourceType": "module" - }, - "plugins": ["lit"], - "rules": { - "accessor-pairs": "error", - "array-bracket-newline": "error", - "array-bracket-spacing": "error", - "array-callback-return": "error", - "array-element-newline": "error", - "arrow-body-style": "error", - "arrow-parens": "error", - "arrow-spacing": ["error", { - "after": true, - "before": true - }], - "block-scoped-var": "error", - "block-spacing": "error", - "brace-style": "error", - "callback-return": "error", - "camelcase": "error", - "capitalized-comments": "off", - "class-methods-use-this": "off", - "comma-dangle": "off", - "comma-spacing": ["error", { - "after": true, - "before": false - }], - "comma-style": ["error", "last"], - "complexity": "error", - "computed-property-spacing": "error", - "consistent-return": "error", - "consistent-this": "error", - "curly": "error", - "default-case": "error", - "default-param-last": "error", - "dot-location": "error", - "dot-notation": "error", - "eol-last": "off", - "eqeqeq": "error", - "func-call-spacing": "error", - "func-name-matching": "error", - "func-names": "off", - "func-style": "error", - "function-paren-newline": "error", - "generator-star-spacing": "error", - "global-require": "error", - "grouped-accessor-pairs": "error", - "guard-for-in": "error", - "handle-callback-err": "error", - "id-blacklist": "error", - "id-length": "error", - "id-match": "error", - "implicit-arrow-linebreak": "error", - "indent": "off", - "indent-legacy": "off", - "init-declarations": "error", - "jsx-quotes": "error", - "key-spacing": "off", - "keyword-spacing": ["error", { - "after": true, - "before": true - }], - "line-comment-position": "error", - "linebreak-style": ["error", "unix"], - "lines-around-comment": "error", - "lines-around-directive": "error", - "lines-between-class-members": ["error", "always"], - "max-classes-per-file": "error", - "max-depth": "error", - "max-len": "off", - "max-lines": "error", - "max-lines-per-function": "off", - "max-nested-callbacks": "error", - "max-params": "error", - "max-statements": "error", - "max-statements-per-line": "error", - "multiline-comment-style": "off", - "new-cap": "error", - "new-parens": "error", - "newline-after-var": "error", - "newline-before-return": "error", - "newline-per-chained-call": "error", - "no-alert": "error", - "no-array-constructor": "error", - "no-await-in-loop": "error", - "no-bitwise": "error", - "no-buffer-constructor": "error", - "no-caller": "error", - "no-catch-shadow": "error", - "no-confusing-arrow": "error", - "no-console": "error", - "no-constructor-return": "error", - "no-continue": "error", - "no-div-regex": "error", - "no-dupe-else-if": "error", - "no-duplicate-imports": "error", - "no-else-return": "error", - "no-empty-function": "off", - "no-eq-null": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-extra-parens": "error", - "no-floating-decimal": "error", - "no-implicit-coercion": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-import-assign": "error", - "no-inline-comments": "error", - "no-invalid-this": "off", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-lonely-if": "error", - "no-loop-func": "error", - "no-magic-numbers": "error", - "no-mixed-operators": "error", - "no-mixed-requires": "error", - "no-multi-assign": "error", - "no-multi-spaces": "error", - "no-multi-str": "error", - "no-multiple-empty-lines": "error", - "no-native-reassign": "error", - "no-negated-condition": "error", - "no-negated-in-lhs": "error", - "no-nested-ternary": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-object": "error", - "no-new-require": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-param-reassign": "error", - "no-path-concat": "error", - "no-plusplus": "error", - "no-process-env": "error", - "no-process-exit": "error", - "no-proto": "error", - "no-restricted-globals": "error", - "no-restricted-imports": "error", - "no-restricted-modules": "error", - "no-restricted-properties": "error", - "no-restricted-syntax": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-setter-return": "error", - "no-shadow": "error", - "no-spaced-func": "error", - "no-sync": "error", - "no-tabs": "error", - "no-template-curly-in-string": "error", - "no-ternary": "off", - "no-throw-literal": "error", - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-undefined": "off", - "no-underscore-dangle": "error", - "no-unmodified-loop-condition": "error", - "no-unneeded-ternary": "error", - "no-unused-expressions": "error", - "no-use-before-define": "error", - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "error", - "no-void": "error", - "no-warning-comments": "error", - "no-whitespace-before-property": "error", - "nonblock-statement-body-position": "error", - "object-curly-newline": "error", - "object-curly-spacing": "off", - "object-property-newline": "error", - "object-shorthand": "error", - "one-var": "error", - "one-var-declaration-per-line": "error", - "operator-assignment": "error", - "operator-linebreak": "error", - "padded-blocks": "off", - "padding-line-between-statements": "error", - "prefer-arrow-callback": "error", - "prefer-const": "error", - "prefer-destructuring": "error", - "prefer-exponentiation-operator": "error", - "prefer-named-capture-group": "error", - "prefer-numeric-literals": "error", - "prefer-object-spread": "error", - "prefer-promise-reject-errors": "error", - "prefer-reflect": "error", - "prefer-regex-literals": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "quote-props": "off", - "quotes": "off", - "radix": "error", - "require-await": "error", - "require-jsdoc": "error", - "require-unicode-regexp": "error", - "rest-spread-spacing": ["error", "never"], - "semi": "off", - "semi-spacing": "error", - "semi-style": ["error", "last"], - "sort-keys": "off", - "sort-vars": "error", - "space-before-blocks": "error", - "space-before-function-paren": "off", - "space-in-parens": ["error", "never"], - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": ["error", "always"], - "strict": "error", - "switch-colon-spacing": "error", - "symbol-description": "error", - "template-curly-spacing": ["error", "never"], - "template-tag-spacing": ["error", "never"], - "unicode-bom": ["error", "never"], - "valid-jsdoc": "error", - "vars-on-top": "error", - "wrap-iife": "error", - "wrap-regex": "error", - "yield-star-spacing": "error", - "yoda": ["error", "never"] - } -}; diff --git a/.stylelintrc b/.stylelintrc index 6adf515..7f4a74d 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,9 +1,109 @@ { - "extends": "stylelint-config-recommended", + "extends": ["stylelint-config-recommended", "stylelint-config-idiomatic-order", "stylelint-config-standard-scss"], + "plugins": [ + "stylelint-scss" + ], "rules": { - "no-duplicate-selectors": null, - "font-family-no-duplicate-names": null, - "no-descending-specificity": null, - "selector-type-no-unknown": null + "alpha-value-notation": "number", + "at-rule-empty-line-before": [ "always", { + "except": [ + "after-same-name", + "blockless-after-same-name-blockless", + "first-nested" + ], + "ignore": [ + "after-comment", + "blockless-after-blockless" + ] + } ], + "at-rule-no-unknown": null, + "color-function-notation": "modern", + "color-named": "never", + "declaration-block-no-duplicate-custom-properties": true, + "declaration-block-no-duplicate-properties": true, + "declaration-block-no-redundant-longhand-properties": true, + "declaration-no-important": true, + "font-family-name-quotes": "always-where-recommended", + "font-weight-notation": "numeric", + "function-url-no-scheme-relative": true, + "function-url-quotes": "always", + "hue-degree-notation": "angle", + "max-nesting-depth": 2, + "named-grid-areas-no-invalid": true, + "no-empty-source": null, + "no-unknown-animations": true, + "no-invalid-position-at-import-rule": null, + "scss/at-else-closing-brace-newline-after": "always-last-in-chain", + "scss/at-else-closing-brace-space-after": "always-intermediate", + "scss/at-else-empty-line-before": "never", + "scss/at-else-if-parentheses-space-before": "always", + "scss/at-function-parentheses-space-before": "never", + "scss/at-if-closing-brace-newline-after": "always-last-in-chain", + "scss/at-if-closing-brace-space-after": "always-intermediate", + "scss/at-if-no-null": true, + "scss/at-import-partial-extension": null, + "scss/at-mixin-parentheses-space-before": "never", + "scss/at-rule-conditional-no-parentheses": true, + "scss/at-rule-no-unknown": true, + "scss/comment-no-empty": true, + "scss/declaration-nested-properties-no-divided-groups": true, + "scss/dollar-variable-colon-newline-after": "always-multi-line", + "scss/dollar-variable-colon-space-after": "always-single-line", + "scss/dollar-variable-colon-space-before": "never", + "scss/dollar-variable-empty-line-before": [ + "always", + { + "except": [ + "first-nested", + "after-dollar-variable" + ], + "ignore": [ + "after-comment", + "inside-single-line-block" + ] + } + ], + "scss/dollar-variable-first-in-block": [ + true, + { + "ignore": [ + "comments", + "imports" + ] + } + ], + "scss/dollar-variable-no-missing-interpolation": true, + "scss/double-slash-comment-whitespace-inside": "always", + "scss/map-keys-quotes": "always", + "scss/no-duplicate-dollar-variables": true, + "scss/no-duplicate-mixins": true, + "scss/no-global-function-names": true, + "scss/operator-no-newline-after": true, + "scss/operator-no-newline-before": true, + "scss/operator-no-unspaced": true, + "scss/selector-nest-combinators": "always", + "scss/selector-no-redundant-nesting-selector": true, + "selector-attribute-quotes": "always", + "selector-class-pattern": "^[a-z][a-zA-Z0-9]+$", + "selector-id-pattern": "^[a-z][a-zA-Z0-9]+$", + "selector-max-attribute": 1, + "selector-max-class": 1, + "selector-max-combinators": 1, + "selector-max-compound-selectors": 2, + "selector-max-id": 1, + "selector-max-pseudo-class": 2, + "selector-max-type": 1, + "selector-max-universal": 1, + "selector-no-qualifying-type": true, + "selector-pseudo-element-colon-notation": "single", + "selector-type-no-unknown": [ + true, + { + "ignore": [ + "custom-elements" + ] + } + ], + "shorthand-property-no-redundant-values": true } } diff --git a/src/alaskaStyle.scss b/src/alaskaStyle.scss index b068ba4..1ed0856 100644 --- a/src/alaskaStyle.scss +++ b/src/alaskaStyle.scss @@ -9,6 +9,8 @@ // Support for auroElement styles @import "./../node_modules/@aurodesignsystem/webcorestylesheets/dist/auroElement/auroElement"; +/* stylelint-disable rule-empty-line-before, scss/comment-no-empty, scss/double-slash-comment-empty-line-before */ + :host { display: inline-block; // listing both legacy and newer tokens to support diff --git a/src/auro-alaska.mjs b/src/auro-alaska.js similarity index 90% rename from src/auro-alaska.mjs rename to src/auro-alaska.js index 9507d60..09063ff 100644 --- a/src/auro-alaska.mjs +++ b/src/auro-alaska.js @@ -4,9 +4,11 @@ // --------------------------------------------------------------------- +/* eslint-disable jsdoc/require-description-complete-sentence */ + import { html, css } from "lit"; import { classMap } from 'lit/directives/class-map.js'; -import BaseIcon from "./baseIcon.mjs"; +import BaseIcon from "./baseIcon.js"; import as400 from '@alaskaairux/icons/dist/restricted/AS-400.mjs'; import as300 from '@alaskaairux/icons/dist/restricted/AS-300.mjs'; @@ -37,7 +39,8 @@ class AuroAlaska extends BaseIcon { } /** - * @private internal defaults + * Internal defaults. + * @private * @returns {void} */ privateDefaults() { @@ -69,9 +72,10 @@ class AuroAlaska extends BaseIcon { } /** - * @private async function to decide which logo to use - * @param {number} iconWidth size of parent icon is in - * @returns {object} SVG to be appended to DOM + * Async function to decide which logo to use. + * @private + * @param {number} iconWidth - Size of parent icon is in. + * @returns {void} */ alaskaLogoDef(iconWidth) { if (this.alaska) { @@ -88,9 +92,10 @@ class AuroAlaska extends BaseIcon { } /** - * @private async function to decide which logo to use - * @param {number} iconWidth size of parent icon is in - * @returns {object} SVG to be appended to DOM + * Async function to decide which logo to use. + * @private + * @param {number} iconWidth - Size of parent icon is in. + * @returns {void} */ alaskaOfficialDef(iconWidth) { if (this.official) { @@ -136,7 +141,7 @@ class AuroAlaska extends BaseIcon { const classes = { 'icon': true, 'logo': this.alaska || this.official, - } + }; return html`
diff --git a/src/auro-icon.mjs b/src/auro-icon.js similarity index 96% rename from src/auro-icon.mjs rename to src/auro-icon.js index a9df278..508cd46 100644 --- a/src/auro-icon.mjs +++ b/src/auro-icon.js @@ -1,14 +1,14 @@ -/* eslint-disable one-var */ -/* eslint-disable no-console */ // Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license // See LICENSE in the project root for license information. // --------------------------------------------------------------------- +/* eslint-disable one-var, no-console, jsdoc/require-description-complete-sentence */ + import { html, css } from "lit"; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; -import BaseIcon from "./baseIcon.mjs"; +import BaseIcon from "./baseIcon.js"; import styleCss from "./iconStyle-css.js"; // See https://git.io/JJ6SJ for "How to document your components using JSDoc" @@ -44,7 +44,8 @@ export class AuroIcon extends BaseIcon { } /** - * @private internal defaults + * Internal Defaults. + * @private * @returns {void} */ /* eslint-disable max-statements */ @@ -141,12 +142,12 @@ export class AuroIcon extends BaseIcon { 'advisory': this.advisory, 'warning': this.warning, 'label': this.label - } + }; const a11y = { 'labelContainer': true, 'util_displayHiddenVisually': !this.label - } + }; return html`
response.text()] @@ -21,7 +23,7 @@ const cacheFetch = (uri, options = {}) => { if (!_fetchMap.has(uri)) { _fetchMap.set(uri, fetch(uri).then(responseParser)); } - return _fetchMap.get(uri); -} + return _fetchMap.get(uri); +}; -export default cacheFetch; \ No newline at end of file +export default cacheFetch; diff --git a/src/iconStyle.scss b/src/iconStyle.scss index 5390c70..89aec79 100644 --- a/src/iconStyle.scss +++ b/src/iconStyle.scss @@ -8,6 +8,8 @@ @import "./../node_modules/@aurodesignsystem/webcorestylesheets/dist/auroElement/auroElement"; +/* stylelint-disable rule-empty-line-before, scss/comment-no-empty */ + :host { display: inline-block; line-height: unset; diff --git a/src/style.scss b/src/style.scss index 06a295c..1c82199 100644 --- a/src/style.scss +++ b/src/style.scss @@ -12,6 +12,8 @@ @import "./../node_modules/@alaskaairux/icons/dist/icons"; +/* stylelint-disable value-keyword-case, order/properties-order */ + :host { color: currentColor; vertical-align: middle; diff --git a/test/auro-icon.test.js b/test/auro-icon.test.js index ea29919..7159ae5 100644 --- a/test/auro-icon.test.js +++ b/test/auro-icon.test.js @@ -8,8 +8,8 @@ /* eslint-disable no-undef */ import { fixture, html, expect, waitUntil } from '@open-wc/testing'; import sinon from 'sinon'; -import '../src/auro-icon.mjs'; -import '../src/auro-alaska.mjs'; +import '../src/auro-icon.js'; +import '../src/auro-alaska.js'; const fetchStub = sinon.stub(window, 'fetch');