diff --git a/README.md b/README.md index de954e8b..ebd322fb 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) [![NPM downloads](https://img.shields.io/npm/dy/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) [![NPM downloads](https://img.shields.io/npm/dt/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) +[![Build Status](https://travis-ci.com/ota-meshi/eslint-plugin-vue-scoped-css.svg?branch=master)](https://travis-ci.com/ota-meshi/eslint-plugin-vue-scoped-css) @@ -19,6 +19,9 @@ This ESLint plugin provides linting rules specific to [Scoped CSS in Vue.js]. +- Enforce best practices for Scoped CSS. +- Supports CSS and SCSS syntax. + You can check on the [Online DEMO](https://ota-meshi.github.io/eslint-plugin-vue-scoped-css/playground/). @@ -59,8 +62,8 @@ module.exports = { This plugin provides 3 predefined configs: -- `plugin:vue-scoped-css/base` - Settings and rules to enable correct ESLint parsing -- `plugin:vue-scoped-css/recommended` - Above, plus rules to improve code experience +- `plugin:vue-scoped-css/base` - Settings and rules to enable this plugin +- `plugin:vue-scoped-css/recommended` - Above, plus rules for better ways to help you avoid problems - `plugin:vue-scoped-css/all` - All rules of this plugin are included ## Rules @@ -71,7 +74,7 @@ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/comm -### Base Rules (Enabling Correct ESLint Parsing) +### Base Rules (Enabling Plugin) Enable this plugin using with: @@ -81,7 +84,7 @@ Enable this plugin using with: } ``` -### Recommended (Improve Development Experience) +### Recommended Enforce all the rules in this category with: diff --git a/docs/.vuepress/categories.js b/docs/.vuepress/categories.js index ae92276c..069bb4cd 100644 --- a/docs/.vuepress/categories.js +++ b/docs/.vuepress/categories.js @@ -1,8 +1,8 @@ const { rules } = require("../../dist/utils/rules") const categoryTitles = { - base: "Base Rules (Enabling Correct ESLint Parsing)", - recommended: "Recommended (Improve Development Experience)", + base: "Base Rules (Enabling Plugin)", + recommended: "Recommended", } const categoryConfigDescriptions = { diff --git a/docs/README.md b/docs/README.md index 6a80130a..5736d394 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,8 +9,8 @@ [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) [![NPM downloads](https://img.shields.io/npm/dy/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) [![NPM downloads](https://img.shields.io/npm/dt/eslint-plugin-vue-scoped-css.svg)](http://www.npmtrends.com/eslint-plugin-vue-scoped-css) +[![Build Status](https://travis-ci.com/ota-meshi/eslint-plugin-vue-scoped-css.svg?branch=master)](https://travis-ci.com/ota-meshi/eslint-plugin-vue-scoped-css) @@ -19,6 +19,9 @@ This ESLint plugin provides linting rules specific to [Scoped CSS in Vue.js]. +- Enforce best practices for Scoped CSS. +- Supports CSS and SCSS syntax. + You can check on the [Online DEMO](./playground/). ## Installation @@ -51,8 +54,8 @@ module.exports = { This plugin provides 3 predefined configs: -- `plugin:vue-scoped-css/base` - Settings and rules to enable correct ESLint parsing -- `plugin:vue-scoped-css/recommended` - Above, plus rules to improve code experience +- `plugin:vue-scoped-css/base` - Settings and rules to enable this plugin +- `plugin:vue-scoped-css/recommended` - Above, plus rules for better ways to help you avoid problems - `plugin:vue-scoped-css/all` - All rules of this plugin are included ## Rules diff --git a/docs/rules/README.md b/docs/rules/README.md index b9a56c7b..64260deb 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -6,7 +6,7 @@ sidebarDepth: 0 -## Base Rules (Enabling Correct ESLint Parsing) +## Base Rules (Enabling Plugin) Enable this plugin using with: @@ -16,7 +16,7 @@ Enable this plugin using with: } ``` -## Recommended (Improve Development Experience) +## Recommended Enforce all the rules in this category with: diff --git a/lib/types.ts b/lib/types.ts index 06b8db49..3df963e8 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -30,8 +30,14 @@ export interface VDirectiveKeyV5 extends AST.HasLocation, AST.HasParent { type: "VDirectiveKey" name: string argument: string | null - modifiers: [string] + modifiers: string[] + parent: AST.VAttribute shorthand: boolean + raw: { + name: string + argument: string | null + modifiers: string[] + } } export interface VDirectiveKeyV6 extends AST.HasLocation, AST.HasParent { type: "VDirectiveKey" diff --git a/package-lock.json b/package-lock.json index 597b80ef..70167e95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10111,7 +10111,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/postcss-safe-parser/-/postcss-safe-parser-4.0.1.tgz", "integrity": "sha512-xZsFA3uX8MO3yAda03QrG3/Eg1LN3EPfjjf07vke/46HERLZyHrTsQ9E1r1w1W//fWEhtYNndo2hQplN2cVpCQ==", - "dev": true, "requires": { "postcss": "^7.0.0" } diff --git a/package.json b/package.json index 2f82c80d..fa36103e 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "mocha": "^6.2.2", "nyc": "^14.1.1", "pack": "^2.2.0", - "postcss-safe-parser": "^4.0.1", "raw-loader": "^3.1.0", "rimraf": "^3.0.0", "ts-node": "^8.4.1", @@ -74,6 +73,7 @@ "eslint-utils": "^1.4.3", "lodash": "^4.17.15", "postcss": "^7.0.21", + "postcss-safe-parser": "^4.0.1", "postcss-scss": "^2.0.0", "postcss-selector-parser": "^6.0.2", "vue-eslint-parser": "^5.0.0 || ^6.0.0 || ^7.0.0" diff --git a/tests/lib/rules/no-parsing-error.ts b/tests/lib/rules/no-parsing-error.ts index 3fd19816..adfb2503 100644 --- a/tests/lib/rules/no-parsing-error.ts +++ b/tests/lib/rules/no-parsing-error.ts @@ -12,6 +12,7 @@ const tester = new RuleTester({ tester.run("no-parsing-error", rule, { valid: [ ` + @@ -20,6 +21,7 @@ tester.run("no-parsing-error", rule, { invalid: [ { code: ` + @@ -27,7 +29,7 @@ tester.run("no-parsing-error", rule, { errors: [ { message: "Parsing error: Unclosed block.", - line: 3, + line: 4, column: 13, }, ], diff --git a/tests/lib/styles/parser/index.ts b/tests/lib/styles/parser/index.ts index b7c76698..1a88dc40 100644 --- a/tests/lib/styles/parser/index.ts +++ b/tests/lib/styles/parser/index.ts @@ -66,6 +66,9 @@ describe("CSS Nodes Test.", () => { if (!style.cssNode) { throw new Error("invalid") } + if (style.cssNode.errors.length) { + return + } checkCSSNodeLocations(source, style.cssNode, style.lang) }) it("should be parsed to valid AST.", () => { diff --git a/tools/lib/categories.ts b/tools/lib/categories.ts index a7680e02..cb5b644e 100644 --- a/tools/lib/categories.ts +++ b/tools/lib/categories.ts @@ -2,8 +2,8 @@ import { rules } from "../../lib/utils/rules" import { Rule } from "../../lib/types" const categoryTitles = { - base: "Base Rules (Enabling Correct ESLint Parsing)", - recommended: "Recommended (Improve Development Experience)", + base: "Base Rules (Enabling Plugin)", + recommended: "Recommended", } as { [key: string]: string } const categoryConfigDescriptions = {