Skip to content

Commit 72b0ed8

Browse files
author
Jeff Rooks
committed
ignore style tags in svelte files for eslint
1 parent 026a4b6 commit 72b0ed8

11 files changed

+69
-37
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/**
2-
./*.config.js
2+
*.config.js
3+
svelte-jest.js

.eslintrc.json .eslintrc.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
{
2-
"env": {
1+
module.exports = {
2+
env: {
33
"jest/globals": true,
44
"browser": true,
55
"es6": true
66
},
7-
"parserOptions": {
7+
parserOptions: {
88
"ecmaVersion": 2019,
99
"sourceType": "module"
1010
},
11-
"plugins": [
11+
plugins: [
1212
"jest",
1313
"svelte3"
1414
],
15-
"extends": [
15+
settings: {
16+
"svelte3/ignore-styles": attributes => attributes.lang && attributes.lang.includes('scss')
17+
},
18+
extends: [
1619
"eslint:recommended"
1720
],
18-
"overrides": [
21+
overrides: [
1922
{
20-
"files": [
23+
files: [
2124
"src/date-range-picker/**/*.svelte",
2225
"src/date-range-picker/*.svelte"
2326
],
24-
"processor": "svelte3/svelte3"
27+
processor: "svelte3/svelte3"
2528
}
2629
],
27-
"rules": {
30+
rules: {
2831
"comma-dangle": "error",
29-
"quotes": ["error", "double"],
30-
"semi": ["error", "never"]
32+
quotes: ["error", "double"],
33+
semi: ["error", "never"]
3134
}
3235
}

coverage/badge-branches.svg

-1
This file was deleted.

coverage/badge-functions.svg

-1
This file was deleted.

coverage/badge-lines.svg

-1
This file was deleted.

coverage/badge-statements.svg

-1
This file was deleted.

src/date-range-picker/components/Day.svelte

+6-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
}
8888
</script>
8989

90-
<style>
90+
<style lang="scss" type="text/scss">
91+
@import "src/date-range-picker/themes/variables.scss";
92+
9193
.s-day {
9294
position: relative;
9395
}
@@ -100,7 +102,7 @@
100102
}
101103
102104
.s-day:not(.disabled):not(.next-month):not(.prev-month)::after {
103-
background-color: #bbdefb;
105+
background-color: $withinSelection;
104106
}
105107
106108
.within-selection:not(.start-date):not(.end-date)::after {
@@ -128,7 +130,7 @@
128130
}
129131
130132
button:focus {
131-
box-shadow: inset 0 0 0 1px #1565c0;
133+
box-shadow: inset 0 0 0 2px $primaryColor;
132134
}
133135
134136
.end-date::after {
@@ -165,7 +167,7 @@
165167
.start-date:not(.next-month):not(.prev-month) button,
166168
.end-date:not(.next-month):not(.prev-month) button,
167169
button:not(:disabled):hover {
168-
background-color: #1565c0;
170+
background-color: $primaryColor;
169171
/* Overwrite .muted class for prev/next months */
170172
color: white !important;
171173
}

src/date-range-picker/themes/s-date-range-picker.default.scss

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
$borderColor: lightgray;
2-
$borderRadius: 4px;
1+
@import "./variables.scss";
2+
3+
34

45
.s-date-range-picker {
5-
font-family: "Cera Pro", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
6+
font-family: $font-family;
67
background-color: #fff;
78
padding: 16px;
89
border: 1px solid $borderColor;
910
border-radius: $borderRadius;
11+
user-select: none;
1012

1113
& > label {
1214
display: block;
@@ -23,9 +25,8 @@ $borderRadius: 4px;
2325
}
2426

2527
select, button {
26-
font-family: "Cera Pro", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
28+
font-family: $font-family;
2729
cursor: pointer;
28-
user-select: none;
2930
}
3031

3132
:disabled {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$primaryColor: #1565c0;
2+
$withinSelection: #bbdefb;
3+
$font-family: "Cera Pro", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
4+
$borderColor: lightgray;
5+
$borderRadius: 4px;

svelte-jest.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const deasync = require('deasync')
2-
const rollup = require('rollup')
1+
const deasync = require("deasync")
2+
const rollup = require("rollup")
33

4-
const config = require('./rollup.config.js')
4+
const config = require("./rollup.config.js")
55

66
exports.process = (...args) => {
77
const [, input] = args
88
const compiled = {}
99
rollup
1010
.rollup({ input, plugins: config.plugins })
11-
.then(bundle => bundle.generate({ format: 'cjs', sourcemap: true }))
11+
.then(bundle => bundle.generate({ format: "cjs", sourcemap: true }))
1212
.then(({ output }) =>
1313
output.reduce((carry, record) => Object.assign(carry, record), compiled)
1414
)

svelte.config.js

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const sass = require("node-sass")
12
/**
23
* @todo Use this file in rollup.config.js to add preprocessor for TypeScript
34
*/
@@ -10,12 +11,35 @@ const {
1011
const env = createEnv()
1112

1213
module.exports = {
13-
preprocess: preprocess({
14-
env,
15-
compilerOptions: {
16-
...readConfigFile(env),
17-
allowNonTsExtensions: true,
18-
customElement: true
19-
}
20-
})
14+
preprocess: {
15+
style: async ({ content, attributes }) => {
16+
if (attributes.type !== "text/scss" && attributes.lang !== "scss") return // lang is now taken into account
17+
18+
return new Promise((resolve, reject) => {
19+
sass.render({
20+
data: content,
21+
includePaths: ["src"],
22+
sourceMap: true,
23+
outFile: "x" // this is necessary, but is ignored
24+
},
25+
(err, result) => {
26+
if (err) return reject(err)
27+
28+
resolve({
29+
code: result.css.toString(),
30+
map: result.map.toString()
31+
})
32+
}
33+
)
34+
})
35+
},
36+
typescript: preprocess({
37+
env,
38+
compilerOptions: {
39+
...readConfigFile(env),
40+
allowNonTsExtensions: true,
41+
customElement: true
42+
}
43+
})
44+
}
2145
}

0 commit comments

Comments
 (0)