Update linting and integrate prettier

This commit is contained in:
Giuseppe Criscione 2023-12-03 15:08:58 +01:00
parent 15c84ec94d
commit 37c3218c01
7 changed files with 483 additions and 555 deletions

View File

@ -7,6 +7,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = off
[*.md]
trim_trailing_whitespace = false

1
panel/.prettierrc Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -1,100 +0,0 @@
{
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-idiomatic-order"
],
"ignoreFiles": [
"./assets/css/*.css",
"./assets/scss/*.scss",
"./assets/scss/vendor/*.scss"
],
"plugins": [
"stylelint-scss",
"stylelint-order"
],
"rules": {
"at-rule-empty-line-before": ["always", {
"except": [
"first-nested"
],
"ignore": [
"after-comment"
],
"ignoreAtRules": [
"if", "import", "include", "else", "extend", "media"
]
}],
"at-rule-name-space-after": "always",
"at-rule-no-unknown": null,
"at-rule-no-vendor-prefix": true,
"at-rule-semicolon-space-before": "never",
"block-closing-brace-newline-after": ["always", {
"ignoreAtRules": [
"if"
]
}],
"color-function-notation": null,
"color-hex-case": "lower",
"color-hex-length": "short",
"color-named": "never",
"comment-whitespace-inside": "always",
"declaration-block-trailing-semicolon": "always",
"declaration-colon-space-before": "never",
"declaration-colon-space-after": "always",
"declaration-block-no-duplicate-custom-properties": true,
"declaration-block-no-duplicate-properties": true,
"font-family-no-duplicate-names": true,
"indentation": 4,
"keyframes-name-pattern": null,
"max-line-length": 180,
"media-feature-range-operator-space-before": "always",
"media-feature-range-operator-space-after": "always",
"media-feature-parentheses-space-inside": "never",
"media-feature-colon-space-before": "never",
"media-feature-colon-space-after": "always",
"no-descending-specificity": true,
"no-duplicate-at-import-rules": true,
"no-duplicate-selectors": true,
"number-max-precision": 5,
"number-leading-zero": "always",
"property-no-vendor-prefix": null,
"scss/at-extend-no-missing-placeholder": null,
"scss/at-import-no-partial-leading-underscore": true,
"scss/at-rule-no-unknown": true,
"scss/dollar-variable-colon-space-after": "always",
"scss/dollar-variable-colon-space-before": "never",
"scss/dollar-variable-empty-line-before": null,
"scss/dollar-variable-first-in-block": [true, {
"ignore": [
"comments", "imports"
]
}],
"scss/dollar-variable-no-missing-interpolation": true,
"scss/no-duplicate-dollar-variables": [true, {
"ignoreInside": "at-rule"
}],
"scss/no-duplicate-mixins": true,
"scss/no-global-function-names": true,
"scss/operator-no-unspaced": true,
"rule-empty-line-before": ["always", {
"except": [
"after-single-line-comment"
],
"ignore": [
"inside-block"
]
}],
"selector-class-pattern": null,
"selector-combinator-space-after": "always",
"selector-list-comma-newline-after": "always-multi-line",
"selector-no-vendor-prefix": null,
"selector-pseudo-element-colon-notation": "double",
"shorthand-property-no-redundant-values": null,
"string-quotes": "single",
"value-keyword-case": ["lower", {
"ignoreProperties": [
"/^\\$/"
]
}]
}
}

136
panel/.stylelintrc.yaml Normal file
View File

@ -0,0 +1,136 @@
extends:
- stylelint-config-standard-scss
ignoreFiles:
- "./assets/css/*.css"
- "./assets/scss/*.scss"
- "./assets/scss/vendor/*.scss"
plugins:
- stylelint-scss
- stylelint-order
rules:
at-rule-empty-line-before:
- always
- except:
- first-nested
ignore:
- after-comment
ignoreAtRules:
- if
- import
- include
- else
- extend
- media
at-rule-no-unknown:
at-rule-no-vendor-prefix: true
color-function-notation:
color-hex-length: short
color-named: never
comment-whitespace-inside: always
declaration-block-no-duplicate-custom-properties: true
declaration-block-no-duplicate-properties: true
font-family-no-duplicate-names: true
keyframes-name-pattern:
no-descending-specificity: true
no-duplicate-at-import-rules: true
no-duplicate-selectors: true
number-max-precision: 5
property-no-vendor-prefix:
scss/at-extend-no-missing-placeholder:
scss/load-no-partial-leading-underscore: true
scss/at-rule-no-unknown: true
scss/dollar-variable-colon-space-after: always
scss/dollar-variable-colon-space-before: never
scss/dollar-variable-empty-line-before:
scss/dollar-variable-first-in-block:
- true
- ignore:
- comments
- imports
scss/dollar-variable-no-missing-interpolation: true
scss/no-duplicate-dollar-variables:
- true
- ignoreInside: at-rule
scss/no-duplicate-mixins: true
scss/no-global-function-names: true
scss/operator-no-unspaced: true
rule-empty-line-before:
- always
- except:
- after-single-line-comment
ignore:
- inside-block
selector-class-pattern:
selector-no-vendor-prefix:
selector-pseudo-element-colon-notation: double
shorthand-property-no-redundant-values:
value-keyword-case:
- lower
- ignoreProperties:
- "/^\\$/"
order/properties-order:
- - composes
- all
- position
- z-index
- top
- right
- bottom
- left
- display
- overflow
- width
- min-width
- max-width
- height
- min-height
- max-height
- box-sizing
- flex
- flex-basis
- flex-direction
- flex-flow
- flex-grow
- flex-shrink
- flex-wrap
- align-content
- align-items
- align-self
- justify-content
- order
- padding
- padding-top
- padding-right
- padding-bottom
- padding-left
- border
- border-width
- border-style
- border-color
- border-radius
- border-top
- border-top-width
- border-top-style
- border-top-color
- border-top-radius
- border-right
- border-right-width
- border-right-style
- border-right-color
- border-right-radius
- border-bottom
- border-bottom-width
- border-bottom-style
- border-bottom-color
- border-bottom-radius
- border-left
- border-left-width
- border-left-style
- border-left-color
- border-left-radius
- margin
- margin-top
- margin-right
- margin-bottom
- margin-left
- unspecified: bottomAlphabetical

View File

@ -1,61 +1,40 @@
import js from '@eslint/js';
import globals from 'globals';
import js from "@eslint/js";
import globals from "globals";
import eslintConfigPrettier from "eslint-config-prettier";
export default [
js.configs.recommended,
{
'languageOptions': {
'ecmaVersion': 6,
'globals': {
languageOptions: {
ecmaVersion: 11,
globals: {
...globals.browser,
'$': 'readonly',
'$$': 'readonly',
'Formwork': 'readonly',
$: "readonly",
$$: "readonly",
Formwork: "readonly",
},
'sourceType': 'module',
sourceType: "module",
},
'rules': {
'arrow-body-style': ['error', 'as-needed'],
'arrow-parens': ['error'],
'arrow-spacing': ['error'],
'brace-style': ['error', '1tbs'],
'comma-dangle': ['error', { 'objects': 'always-multiline' }],
'curly': ['error', 'all'],
'eqeqeq': ['error', 'always'],
'indent': ['error', 4],
'keyword-spacing': ['error'],
'linebreak-style': ['error', 'unix'],
'new-parens': ['error'],
'no-else-return': ['error'],
'no-lonely-if': ['error'],
'no-multi-spaces': ['error'],
'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-trailing-spaces': ['error'],
'no-unneeded-ternary': ['error'],
'no-var': ['error'],
'object-curly-newline': ['error', { 'multiline': true }],
'object-curly-spacing': ['error', 'always'],
'object-property-newline': ['error'],
'one-var': ['error', {
'initialized': 'never',
'uninitialized': 'always',
}],
'operator-assignment': ['error'],
'prefer-arrow-callback': ['error'],
'prefer-const': ['error'],
'prefer-template': ['error'],
'quotes': ['error', 'single'],
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
}],
'space-infix-ops': ['error'],
'space-unary-ops': ['error', {
'nonwords': false,
'words': true,
}],
'spaced-comment': ['error'],
'template-curly-spacing': ['error', 'never'],
rules: {
"arrow-body-style": ["error", "as-needed"],
curly: ["error", "all"],
eqeqeq: ["error", "always"],
"no-else-return": ["error"],
"no-lonely-if": ["error"],
"no-unneeded-ternary": ["error"],
"no-var": ["error"],
"one-var": [
"error",
{
initialized: "never",
uninitialized: "always",
},
}
],
"operator-assignment": ["error"],
"prefer-arrow-callback": ["error"],
"prefer-const": ["error"],
"prefer-template": ["error"],
},
},
eslintConfigPrettier,
];

View File

@ -17,26 +17,28 @@
"build:js": "esbuild ./src/js/main.js --outfile=./assets/js/app.min.js --bundle --format=iife --global-name=Formwork --target=es6 --minify",
"watch:css": "yarn build:css --watch",
"watch:js": "yarn build:js --watch",
"lint:css": "stylelint './src/scss/**/*.scss' --fix",
"lint:js": "eslint './src/js/**' --fix"
"lint": "yarn lint:css && yarn lint:js",
"lint:css": "prettier './src/scss/**/*.scss' --write && stylelint './src/scss/**/*.scss' --fix",
"lint:js": "prettier './src/js/**/*.js' --write && eslint './src/js/**/*.js' --fix"
},
"dependencies": {
"chartist": "^1.3.0",
"codemirror": "^5.65.11",
"sortablejs": "^1.15.0"
"codemirror": "^5.65.16",
"sortablejs": "^1.15.1"
},
"devDependencies": {
"@eslint/js": "^8.41.0",
"esbuild": "^0.19.2",
"eslint": "^8.40.0",
"globals": "^13.20.0",
"postcss": "^8.4.19",
"sass": "^1.66.1",
"stylelint": "^14.16.1",
"stylelint-config-idiomatic-order": "^9.0.0",
"stylelint-config-standard-scss": "^6.1.0",
"stylelint-order": "^6.0.1",
"stylelint-scss": "^4.7.0"
"@eslint/js": "^8.55.0",
"esbuild": "^0.19.8",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^13.23.0",
"postcss": "^8.4.32",
"prettier": "3.1.0",
"sass": "^1.69.5",
"stylelint": "^15.11.0",
"stylelint-config-standard-scss": "^11.1.0",
"stylelint-order": "^6.0.3",
"stylelint-scss": "^5.3.1"
},
"packageManager": "yarn@4.0.2"
}

File diff suppressed because it is too large Load Diff