eslint-plugin-hex-under 1.2.3 → 1.2.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-hex-under",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "main": "src/eslint-plugin-hex-under.js",
6
6
  "scripts": {
@@ -42,21 +42,15 @@ export default {
42
42
 
43
43
  create(context) {
44
44
  const [{ limit = 15, skipBigInt = false } = {}] = context.options;
45
- let comments = [];
46
45
  return {
47
- Program(node) {
48
- comments = node.comments || [];
49
- },
50
46
  'Literal[raw=/^0[bB][01_]+n?$/]'(node) {
51
47
  const raw = node.raw;
52
48
 
53
- const ignore = comments.some((c) => {
54
- const line = c.loc.end.line;
55
- return (
56
- (line === node.loc.start.line - 1 || line === node.loc.end.line) &&
57
- c.value.trim() === 'ignore-binary-under'
58
- );
59
- });
49
+ const sourceCode = context.sourceCode;
50
+ const line = node.loc.end.line;
51
+ const ignore =
52
+ sourceCode.lines[line - 2]?.startsWith('// ignore-binary-under') ||
53
+ /\/\/\s(ignore-binary-under)/.test(sourceCode.lines[line - 1]);
60
54
  if (ignore) return;
61
55
 
62
56
  const isBigInt = BINARY_REGEX_BIGINT.test(raw);
@@ -4,7 +4,7 @@ const HEX_REGEX_BIGINT = /^0[xX][0-9a-fA-F_]+n$/;
4
4
  export default {
5
5
  meta: {
6
6
  type: 'suggestion',
7
- version: '0.5.0',
7
+ version: '0.6.0',
8
8
  defaultOptions: [
9
9
  {
10
10
  limit: 255,
@@ -43,21 +43,15 @@ export default {
43
43
 
44
44
  create(context) {
45
45
  const [{ limit = 255, skipBigInt = false } = {}] = context.options;
46
- let comments = [];
47
46
  return {
48
- Program(node) {
49
- comments = node.comments || [];
50
- },
51
47
  'Literal[raw=/^0[xX][0-9a-fA-F_]+n?$/]'(node) {
52
48
  const raw = node.raw;
53
49
 
54
- const ignore = comments.some((c) => {
55
- const line = c.loc.end.line;
56
- return (
57
- (line === node.loc.start.line - 1 || line === node.loc.end.line) &&
58
- c.value.trim() === 'ignore-hex-under'
59
- );
60
- });
50
+ const sourceCode = context.sourceCode;
51
+ const line = node.loc.end.line;
52
+ const ignore =
53
+ sourceCode.lines[line - 2]?.startsWith('// ignore-hex-under') ||
54
+ /\/\/\s(ignore-hex-under)/.test(sourceCode.lines[line - 1]);
61
55
  if (ignore) return;
62
56
 
63
57
  const isHexBigInt = HEX_REGEX_BIGINT.test(raw);
@@ -3,7 +3,7 @@ const OCTAL_REGEX_BIGINT = /^0[oO]?[0-7_]+n$/;
3
3
 
4
4
  export default {
5
5
  meta: {
6
- version: '0.1.1',
6
+ version: '0.2.0',
7
7
  type: 'suggestion',
8
8
  docs: {
9
9
  description: 'Ensures octal numbers do not exceed a limit.',
@@ -42,21 +42,15 @@ export default {
42
42
 
43
43
  create(context) {
44
44
  const [{ limit = 511, skipBigInt = false } = {}] = context.options;
45
- let comments = [];
46
45
  return {
47
- Program(node) {
48
- comments = node.comments || [];
49
- },
50
46
  'Literal[raw=/^0[oO]?[0-7_]+n?$/]'(node) {
51
47
  const raw = node.raw;
52
48
 
53
- const ignore = comments.some((c) => {
54
- const line = c.loc.end.line;
55
- return (
56
- (line === node.loc.start.line - 1 || line === node.loc.end.line) &&
57
- c.value.trim() === 'ignore-octal-under'
58
- );
59
- });
49
+ const sourceCode = context.sourceCode;
50
+ const line = node.loc.end.line;
51
+ const ignore =
52
+ sourceCode.lines[line - 2]?.startsWith('// ignore-octal-under') ||
53
+ /\/\/\s(ignore-octal-under)/.test(sourceCode.lines[line - 1]);
60
54
  if (ignore) return;
61
55
 
62
56
  if (