Skip to content

Commit

Permalink
Lint JavaScript with eslint/prettier
Browse files Browse the repository at this point in the history
This uses `@thoughtbot/eslint-config/base`, along with the `prettier`
plugin and configuration for formatting and fixing.

One rule is overidden, as using modules is nice in the tests, but this
avoids changing the existing `index.js`.
  • Loading branch information
nickcharlton committed Feb 1, 2024
1 parent a62f70e commit 96b4414
Show file tree
Hide file tree
Showing 6 changed files with 15,026 additions and 1,931 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["@thoughtbot/eslint-config/base"],
"plugins": ["prettier"],
"rules": {
"import/extensions": "off"
}
}
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
8 changes: 3 additions & 5 deletions __tests__/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ describe('rules', () => {
assert.ok(ruleNames.length > 0);
});

for (const ruleName of ruleNames) {
console.log(ruleName);

ruleNames.forEach((ruleName) => {
it(`${ruleName}`, async () => {
const rule = await stylelint.rules[ruleName];

Expand All @@ -25,8 +23,8 @@ describe('rules', () => {
assert.ok(!rule.meta.deprecated, `the ${ruleName} rule is deprecated`);
}
});
}
})
});
});

describe('with the valid example', () => {
const validScss = fs.readFileSync('./__tests__/valid.scss', 'utf-8');
Expand Down
118 changes: 59 additions & 59 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
module.exports = {
"extends": ["stylelint-config-standard-scss", "stylelint-config-recommended"],
"plugins": [
"stylelint-declaration-block-no-ignored-properties",
"stylelint-order",
extends: ['stylelint-config-standard-scss', 'stylelint-config-recommended'],
plugins: [
'stylelint-declaration-block-no-ignored-properties',
'stylelint-order',
],
"rules": {
"at-rule-no-unknown": null,
"color-hex-length": "long",
"color-named": "never",
"comment-whitespace-inside": "always",
"declaration-block-no-redundant-longhand-properties": true,
"declaration-no-important": true,
"declaration-property-unit-allowed-list": {
"line-height": []
rules: {
'at-rule-no-unknown': null,
'color-hex-length': 'long',
'color-named': 'never',
'comment-whitespace-inside': 'always',
'declaration-block-no-redundant-longhand-properties': true,
'declaration-no-important': true,
'declaration-property-unit-allowed-list': {
'line-height': [],
},
"declaration-property-value-disallowed-list": {
"/^transition/": ["/all/"]
'declaration-property-value-disallowed-list': {
'/^transition/': ['/all/'],
},
"function-url-quotes": "always",
"length-zero-no-unit": true,
"max-nesting-depth": 3,
"no-empty-source": true,
"order/properties-alphabetical-order": true,
"plugin/declaration-block-no-ignored-properties": true,
"property-no-unknown": [
'function-url-quotes': 'always',
'length-zero-no-unit': true,
'max-nesting-depth': 3,
'no-empty-source': true,
'order/properties-alphabetical-order': true,
'plugin/declaration-block-no-ignored-properties': true,
'property-no-unknown': [
true,
{
"ignoreProperties": [
"text-size"
]
}
ignoreProperties: [
'text-size',
],
},
],
"property-no-vendor-prefix": true,
"rule-empty-line-before": [
"always",
'property-no-vendor-prefix': true,
'rule-empty-line-before': [
'always',
{
"except": [
"first-nested"
except: [
'first-nested',
],
ignore: [
'after-comment',
],
"ignore": [
"after-comment"
]
}
},
],
"scss/at-else-if-parentheses-space-before": "never",
"scss/at-extend-no-missing-placeholder": true,
"scss/at-function-parentheses-space-before": "never",
"scss/load-no-partial-leading-underscore": true,
"scss/at-import-partial-extension-blacklist": ["scss"],
"scss/at-mixin-parentheses-space-before": "never",
"scss/at-rule-no-unknown": true,
"scss/dollar-variable-colon-space-after": "always",
"scss/dollar-variable-colon-space-before": "never",
"scss/map-keys-quotes": "always",
"scss/no-duplicate-dollar-variables": true,
"scss/operator-no-unspaced": true,
"scss/selector-no-redundant-nesting-selector": true,
"scss/selector-no-union-class-name": true,
"selector-max-id": 0,
"selector-no-qualifying-type": true,
"selector-no-vendor-prefix": true,
"selector-pseudo-element-colon-notation": "double",
"selector-type-case": "lower",
"shorthand-property-no-redundant-values": true,
"value-keyword-case": "lower",
"value-no-vendor-prefix": true
}
}
'scss/at-else-if-parentheses-space-before': 'never',
'scss/at-extend-no-missing-placeholder': true,
'scss/at-function-parentheses-space-before': 'never',
'scss/load-no-partial-leading-underscore': true,
'scss/at-import-partial-extension-blacklist': ['scss'],
'scss/at-mixin-parentheses-space-before': 'never',
'scss/at-rule-no-unknown': true,
'scss/dollar-variable-colon-space-after': 'always',
'scss/dollar-variable-colon-space-before': 'never',
'scss/map-keys-quotes': 'always',
'scss/no-duplicate-dollar-variables': true,
'scss/operator-no-unspaced': true,
'scss/selector-no-redundant-nesting-selector': true,
'scss/selector-no-union-class-name': true,
'selector-max-id': 0,
'selector-no-qualifying-type': true,
'selector-no-vendor-prefix': true,
'selector-pseudo-element-colon-notation': 'double',
'selector-type-case': 'lower',
'shorthand-property-no-redundant-values': true,
'value-keyword-case': 'lower',
'value-no-vendor-prefix': true,
},
};
Loading

0 comments on commit 96b4414

Please sign in to comment.