eslint-plugin-toml 0.1.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,18 +9,18 @@ const utils_1 = require("../utils");
9
9
  function getFirst(keys) {
10
10
  const first = keys[0];
11
11
  if (first) {
12
- return getFirst(first.keys) || first.firstNode;
12
+ return getFirst(first.keys) || first.node;
13
13
  }
14
14
  return null;
15
15
  }
16
16
  function getLast(keys) {
17
17
  const last = lodash_1.default.last(keys);
18
18
  if (last) {
19
- return getLast(last.keys) || last.lastNode;
19
+ return getLast(last.keys) || last.node;
20
20
  }
21
21
  return null;
22
22
  }
23
- exports.default = utils_1.createRule("tables-order", {
23
+ exports.default = (0, utils_1.createRule)("tables-order", {
24
24
  meta: {
25
25
  docs: {
26
26
  description: "disallow defining tables out-of-order",
@@ -41,40 +41,27 @@ exports.default = utils_1.createRule("tables-order", {
41
41
  }
42
42
  const sourceCode = context.getSourceCode();
43
43
  function applyKey(rootKeys, node) {
44
- const keyNames = toml_eslint_parser_1.getStaticTOMLValue(node.key);
44
+ const keyNames = [...node.resolvedKey];
45
45
  let before = null;
46
46
  let keys = rootKeys;
47
47
  while (keyNames.length) {
48
48
  const key = keyNames.shift();
49
49
  const isLast = !keyNames.length;
50
- const nextIndex = keys.findIndex((e) => e.key === key);
51
- if (nextIndex < 0) {
52
- const targetNode = isLast ? node : null;
53
- const next = {
50
+ let next = keys.find((e) => e.key === key);
51
+ if (!next) {
52
+ next = {
54
53
  key,
55
- array: node.kind === "array" && isLast,
56
- firstNode: targetNode,
57
- lastNode: targetNode,
54
+ node,
58
55
  keys: [],
59
56
  };
60
57
  if (isLast) {
61
58
  before = getLast(keys);
62
59
  }
63
60
  keys.push(next);
64
- keys = next.keys;
65
61
  }
66
62
  else {
67
- const next = keys[nextIndex];
68
- if (next.array) {
69
- if (isLast) {
70
- before = getLast(next.keys) || next.lastNode;
71
- next.lastNode = node;
72
- next.keys = [];
73
- break;
74
- }
75
- }
76
63
  if (isLast) {
77
- if (!next.firstNode && next.keys.length > 0) {
64
+ if (next.keys.length > 0) {
78
65
  const after = getFirst(next.keys);
79
66
  return {
80
67
  before: null,
@@ -83,8 +70,8 @@ exports.default = utils_1.createRule("tables-order", {
83
70
  }
84
71
  before = getLast(keys);
85
72
  }
86
- keys = next.keys;
87
73
  }
74
+ keys = next.keys;
88
75
  }
89
76
  return {
90
77
  before,
@@ -104,8 +91,8 @@ exports.default = utils_1.createRule("tables-order", {
104
91
  node: body.key,
105
92
  messageId: "outOfOrderToBefore",
106
93
  data: {
107
- target: toml_eslint_parser_1.getStaticTOMLValue(body.key).join("."),
108
- after: toml_eslint_parser_1.getStaticTOMLValue(after.key).join("."),
94
+ target: (0, toml_eslint_parser_1.getStaticTOMLValue)(body.key).join("."),
95
+ after: (0, toml_eslint_parser_1.getStaticTOMLValue)(after.key).join("."),
109
96
  },
110
97
  fix(fixer) {
111
98
  const startToken = sourceCode.getTokenBefore(body);
@@ -125,8 +112,8 @@ exports.default = utils_1.createRule("tables-order", {
125
112
  node: body.key,
126
113
  messageId: "outOfOrder",
127
114
  data: {
128
- target: toml_eslint_parser_1.getStaticTOMLValue(body.key).join("."),
129
- before: toml_eslint_parser_1.getStaticTOMLValue(before.key).join("."),
115
+ target: (0, toml_eslint_parser_1.getStaticTOMLValue)(body.key).join("."),
116
+ before: (0, toml_eslint_parser_1.getStaticTOMLValue)(before.key).join("."),
130
117
  },
131
118
  fix(fixer) {
132
119
  const startToken = sourceCode.getTokenBefore(body);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../../utils");
4
- exports.default = utils_1.createRule("vue-custom-block/no-parsing-error", {
4
+ exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
5
5
  meta: {
6
6
  docs: {
7
7
  description: "disallow parsing errors in Vue custom blocks",
package/lib/types.d.ts CHANGED
@@ -35,7 +35,7 @@ export interface RuleMetaData {
35
35
  url: string;
36
36
  ruleId: string;
37
37
  ruleName: string;
38
- replacedBy?: [];
38
+ replacedBy?: string[];
39
39
  default?: "error" | "warn";
40
40
  extensionRule: string | false;
41
41
  };
@@ -43,6 +43,7 @@ export interface RuleMetaData {
43
43
  [messageId: string]: string;
44
44
  };
45
45
  fixable?: "code" | "whitespace";
46
+ hasSuggestions?: boolean;
46
47
  schema: JSONSchema4 | JSONSchema4[];
47
48
  deprecated?: boolean;
48
49
  type: "problem" | "suggestion" | "layout";
@@ -57,7 +58,7 @@ export interface PartialRuleMetaData {
57
58
  docs: {
58
59
  description: string;
59
60
  categories: ("recommended" | "standard")[] | null;
60
- replacedBy?: [];
61
+ replacedBy?: string[];
61
62
  default?: "error" | "warn";
62
63
  extensionRule: string | false;
63
64
  };
@@ -65,6 +66,7 @@ export interface PartialRuleMetaData {
65
66
  [messageId: string]: string;
66
67
  };
67
68
  fixable?: "code" | "whitespace";
69
+ hasSuggestions?: boolean;
68
70
  schema: JSONSchema4 | JSONSchema4[];
69
71
  deprecated?: boolean;
70
72
  type: "problem" | "suggestion" | "layout";
@@ -12,13 +12,13 @@ function capitalize(str) {
12
12
  return str.charAt(0).toUpperCase() + str.slice(1);
13
13
  }
14
14
  function hasSymbols(str) {
15
- return /[!"#%&'()*+,./:;<=>?@[\\\]^`{|}]/u.exec(str);
15
+ return /[\u0021-\u0023\u0025-\u002c./\u003a-\u0040\u005b-\u005e`\u007b-\u007d]/u.test(str);
16
16
  }
17
17
  function hasUpper(str) {
18
- return /[A-Z]/u.exec(str);
18
+ return /[A-Z]/u.test(str);
19
19
  }
20
20
  function hasLower(str) {
21
- return /[a-z]/u.exec(str);
21
+ return /[a-z]/u.test(str);
22
22
  }
23
23
  function kebabCase(str) {
24
24
  let res = str.replace(/_/gu, "-");
@@ -31,8 +31,8 @@ exports.kebabCase = kebabCase;
31
31
  function isKebabCase(str) {
32
32
  if (hasUpper(str) ||
33
33
  hasSymbols(str) ||
34
- /^-/u.exec(str) ||
35
- /_|--|\s/u.exec(str)) {
34
+ str.startsWith("-") ||
35
+ /_|--|\s/u.test(str)) {
36
36
  return false;
37
37
  }
38
38
  return true;
@@ -47,7 +47,7 @@ function snakeCase(str) {
47
47
  }
48
48
  exports.snakeCase = snakeCase;
49
49
  function isSnakeCase(str) {
50
- if (hasUpper(str) || hasSymbols(str) || /-|__|\s/u.exec(str)) {
50
+ if (hasUpper(str) || hasSymbols(str) || /-|__|\s/u.test(str)) {
51
51
  return false;
52
52
  }
53
53
  return true;
@@ -62,7 +62,7 @@ function screamingSnakeCase(str) {
62
62
  }
63
63
  exports.screamingSnakeCase = screamingSnakeCase;
64
64
  function isScreamingSnakeCase(str) {
65
- if (hasLower(str) || hasSymbols(str) || /-|__|\s/u.exec(str)) {
65
+ if (hasLower(str) || hasSymbols(str) || /-|__|\s/u.test(str)) {
66
66
  return false;
67
67
  }
68
68
  return true;
@@ -81,8 +81,8 @@ function camelCase(str) {
81
81
  exports.camelCase = camelCase;
82
82
  function isCamelCase(str) {
83
83
  if (hasSymbols(str) ||
84
- /^[A-Z]/u.exec(str) ||
85
- /-|_|\s/u.exec(str)) {
84
+ /^[A-Z]/u.test(str) ||
85
+ /[\s\-_]/u.test(str)) {
86
86
  return false;
87
87
  }
88
88
  return true;
@@ -94,8 +94,8 @@ function pascalCase(str) {
94
94
  exports.pascalCase = pascalCase;
95
95
  function isPascalCase(str) {
96
96
  if (hasSymbols(str) ||
97
- /^[a-z]/u.exec(str) ||
98
- /-|_|\s/u.exec(str)) {
97
+ /^[a-z]/u.test(str) ||
98
+ /[\s\-_]/u.test(str)) {
99
99
  return false;
100
100
  }
101
101
  return true;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -26,7 +30,7 @@ exports.getCoreRule = exports.convertESNode = exports.getProxyNode = exports.def
26
30
  const tomlESLintParser = __importStar(require("toml-eslint-parser"));
27
31
  const debug_1 = __importDefault(require("debug"));
28
32
  const path_1 = __importDefault(require("path"));
29
- const log = debug_1.default("eslint-plugin-toml:utils/index");
33
+ const log = (0, debug_1.default)("eslint-plugin-toml:utils/index");
30
34
  function createRule(ruleName, rule) {
31
35
  return {
32
36
  meta: Object.assign(Object.assign({}, rule.meta), { docs: Object.assign(Object.assign({}, rule.meta.docs), { url: `https://ota-meshi.github.io/eslint-plugin-toml/rules/${ruleName}.html`, ruleId: `toml/${ruleName}`, ruleName }) }),
@@ -10,6 +10,7 @@ const array_element_newline_1 = __importDefault(require("../rules/array-element-
10
10
  const comma_style_1 = __importDefault(require("../rules/comma-style"));
11
11
  const indent_1 = __importDefault(require("../rules/indent"));
12
12
  const inline_table_curly_spacing_1 = __importDefault(require("../rules/inline-table-curly-spacing"));
13
+ const key_spacing_1 = __importDefault(require("../rules/key-spacing"));
13
14
  const keys_order_1 = __importDefault(require("../rules/keys-order"));
14
15
  const no_mixed_type_in_array_1 = __importDefault(require("../rules/no-mixed-type-in-array"));
15
16
  const no_non_decimal_integer_1 = __importDefault(require("../rules/no-non-decimal-integer"));
@@ -32,6 +33,7 @@ exports.rules = [
32
33
  comma_style_1.default,
33
34
  indent_1.default,
34
35
  inline_table_curly_spacing_1.default,
36
+ key_spacing_1.default,
35
37
  keys_order_1.default,
36
38
  no_mixed_type_in_array_1.default,
37
39
  no_non_decimal_integer_1.default,
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "eslint-plugin-toml",
3
- "version": "0.1.0",
3
+ "version": "0.3.1",
4
4
  "description": "This ESLint plugin provides linting rules for TOML.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
7
7
  "lib"
8
8
  ],
9
+ "engines": {
10
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
11
+ },
9
12
  "scripts": {
10
13
  "prebuild": "npm run -s clean",
11
14
  "build": "npm run build:ts",
12
15
  "build:ts": "tsc --project ./tsconfig.build.json",
13
16
  "clean": "rimraf .nyc_output dist coverage",
14
- "lint": "eslint \"tests\" \"src\" \"docs\" --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml",
15
- "eslint-fix": "eslint \"tests\" \"src\" \"docs\" --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml --fix",
17
+ "lint": "eslint . --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml --ignore-pattern playground",
18
+ "eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.md,.toml,.yaml,.yml --ignore-pattern playground --fix",
16
19
  "pretest:base": "cross-env DEBUG=eslint-plugin-toml*",
17
20
  "test:base": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
18
21
  "test": "npm run test:base",
@@ -23,8 +26,8 @@
23
26
  "predocs:watch": "npm run build:ts",
24
27
  "docs:watch": "vuepress dev --debug docs",
25
28
  "docs:build": "npm run build:ts && vuepress build docs --no-cache",
26
- "preversion": "npm test && npm run update && git add .",
27
- "version": "npm run eslint-fix && git add ."
29
+ "preversion": "npm test && git add .",
30
+ "version": "env-cmd -e version npm run update && git add ."
28
31
  },
29
32
  "repository": {
30
33
  "type": "git",
@@ -39,6 +42,7 @@
39
42
  "formatter"
40
43
  ],
41
44
  "author": "Yosuke Ota",
45
+ "funding": "https://github.com/sponsors/ota-meshi",
42
46
  "license": "MIT",
43
47
  "bugs": {
44
48
  "url": "https://github.com/ota-meshi/eslint-plugin-toml/issues"
@@ -50,48 +54,50 @@
50
54
  "dependencies": {
51
55
  "debug": "^4.1.1",
52
56
  "lodash": "^4.17.19",
53
- "toml-eslint-parser": "^0.1.1"
57
+ "toml-eslint-parser": "^0.4.0"
54
58
  },
55
59
  "devDependencies": {
56
- "@ota-meshi/eslint-plugin": "^0.0.11",
60
+ "@ota-meshi/eslint-plugin": "^0.10.0",
57
61
  "@types/debug": "^4.1.5",
58
- "@types/eslint": "^7.2.0",
62
+ "@types/eslint": "^8.0.0",
59
63
  "@types/eslint-scope": "^3.7.0",
60
64
  "@types/eslint-visitor-keys": "^1.0.0",
61
- "@types/estree": "^0.0.46",
65
+ "@types/estree": "^0.0.51",
62
66
  "@types/lodash": "^4.14.158",
63
- "@types/mocha": "^8.0.0",
64
- "@types/node": "^14.0.13",
67
+ "@types/mocha": "^9.0.0",
68
+ "@types/node": "^16.11.3",
65
69
  "@types/semver": "^7.3.1",
66
- "@typescript-eslint/eslint-plugin": "^4.4.1",
67
- "@typescript-eslint/parser": "^4.4.1",
68
- "babel-eslint": "^10.1.0",
70
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
71
+ "@typescript-eslint/parser": "^5.0.0",
69
72
  "cross-env": "^7.0.2",
70
- "eslint": "^7.3.0",
71
- "eslint-config-prettier": "^7.0.0",
73
+ "env-cmd": "^10.1.0",
74
+ "eslint": "^8.0.0",
75
+ "eslint-config-prettier": "^8.0.0",
72
76
  "eslint-plugin-eslint-comments": "^3.2.0",
73
- "eslint-plugin-eslint-plugin": "^2.3.0",
74
- "eslint-plugin-jsonc": "^0.8.1",
77
+ "eslint-plugin-eslint-plugin": "^4.0.0",
78
+ "eslint-plugin-json-schema-validator": "^2.0.0",
79
+ "eslint-plugin-jsonc": "^2.0.0",
75
80
  "eslint-plugin-markdown": "^2.0.0-0",
76
81
  "eslint-plugin-node": "^11.1.0",
77
- "eslint-plugin-prettier": "^3.1.4",
78
- "eslint-plugin-regexp": "^0.1.1",
79
- "eslint-plugin-vue": "^7.0.1",
80
- "eslint-plugin-yml": "^0.6.0",
82
+ "eslint-plugin-prettier": "^4.0.0",
83
+ "eslint-plugin-regexp": "^1.0.0",
84
+ "eslint-plugin-vue": "^8.0.0",
85
+ "eslint-plugin-yml": "^0.14.0",
81
86
  "eslint4b": "^7.3.1",
82
- "espree": "^7.1.0",
83
- "mocha": "^8.0.0",
87
+ "espree": "^9.0.0",
88
+ "mocha": "^9.0.0",
84
89
  "nyc": "^15.1.0",
85
90
  "prettier": "^2.2.1",
86
91
  "raw-loader": "^4.0.1",
87
92
  "semver": "^7.3.2",
88
- "stylelint": "^13.6.1",
89
- "stylelint-config-standard": "^20.0.0",
90
- "stylelint-plugin-stylus": "^0.9.0",
91
- "ts-node": "^9.0.0",
92
- "typescript": "^4.0.0",
93
+ "stylelint": "^14.0.0",
94
+ "stylelint-config-recommended-vue": "^1.0.0",
95
+ "stylelint-config-standard": "^25.0.0",
96
+ "stylelint-plugin-stylus": "^0.13.0",
97
+ "ts-node": "^10.0.0",
98
+ "typescript": "~4.6.0",
93
99
  "vue-eslint-editor": "^1.1.0",
94
- "vue-eslint-parser": "^7.3.0",
100
+ "vue-eslint-parser": "^8.0.0",
95
101
  "vuepress": "^1.5.2"
96
102
  }
97
103
  }