-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #864 from Webperf-se/stylelint-update
Stylelint - Add autodetect on new stylelint releases
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
from datetime import timedelta | ||
import json | ||
import os | ||
from pathlib import Path | ||
from helpers.setting_helper import get_config | ||
|
||
USE_CACHE = get_config('general.cache.use') | ||
CACHE_TIME_DELTA = timedelta(minutes=get_config('general.cache.max-age')) | ||
CONFIG_WARNINGS = {} | ||
|
||
def update_stylelint_rules(): | ||
print('updates rules used in defaults/css-stylelint-standard.json') | ||
|
||
base_directory = Path(os.path.dirname( | ||
os.path.realpath(__file__)) + os.path.sep).parent | ||
rules_path = os.path.join(base_directory, 'node_modules', 'stylelint', 'lib', 'rules') | ||
rule_names = os.listdir(rules_path) | ||
|
||
rules = {} | ||
for rule_name in rule_names: | ||
if 'no-unknown' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-deprecated' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-invalid' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-vendor' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-empty' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-nonstandard' in rule_name: | ||
rules[rule_name] = True | ||
elif 'no-important' in rule_name: | ||
rules[rule_name] = True | ||
|
||
stylelint_standard_path = os.path.join(base_directory, 'defaults', 'css-stylelint-standard.json') | ||
with open(stylelint_standard_path, 'w', encoding='utf-8') as outfile: | ||
json.dump({ | ||
'rules': rules | ||
}, outfile, indent=4) | ||
|